Add worldguard integration
This commit is contained in:
parent
554e8d13cf
commit
bafc260459
BIN
libs/WorldEdit.jar
Normal file
BIN
libs/WorldEdit.jar
Normal file
Binary file not shown.
BIN
libs/WorldGuard.jar
Normal file
BIN
libs/WorldGuard.jar
Normal file
Binary file not shown.
@ -28,7 +28,7 @@ import com.comphenix.protocol.ProtocolLibrary;
|
|||||||
import com.comphenix.protocol.ProtocolManager;
|
import com.comphenix.protocol.ProtocolManager;
|
||||||
|
|
||||||
public class Chairs extends JavaPlugin {
|
public class Chairs extends JavaPlugin {
|
||||||
public static ChairEffects chairEffects;
|
public ChairEffects chairEffects;
|
||||||
public List<ChairBlock> allowedBlocks;
|
public List<ChairBlock> allowedBlocks;
|
||||||
public List<Material> validSigns;
|
public List<Material> validSigns;
|
||||||
public boolean autoRotate, signCheck, notifyplayer;
|
public boolean autoRotate, signCheck, notifyplayer;
|
||||||
@ -39,11 +39,12 @@ public class Chairs extends JavaPlugin {
|
|||||||
public int sitMaxHealth;
|
public int sitMaxHealth;
|
||||||
public int sitHealthPerInterval;
|
public int sitHealthPerInterval;
|
||||||
public int sitEffectInterval;
|
public int sitEffectInterval;
|
||||||
|
public HashSet<String> disabledRegions = new HashSet<String>();
|
||||||
private File pluginFolder;
|
private File pluginFolder;
|
||||||
private File configFile;
|
private File configFile;
|
||||||
private Logger log;
|
private Logger log;
|
||||||
public PluginManager pm;
|
public PluginManager pm;
|
||||||
public static ChairsIgnoreList ignoreList;
|
public ChairsIgnoreList ignoreList;
|
||||||
public String msgSitting, msgStanding, msgOccupied, msgNoPerm, msgReloaded, msgDisabled, msgEnabled;
|
public String msgSitting, msgStanding, msgOccupied, msgNoPerm, msgReloaded, msgDisabled, msgEnabled;
|
||||||
private ProtocolManager protocolManager;
|
private ProtocolManager protocolManager;
|
||||||
|
|
||||||
@ -225,7 +226,9 @@ public class Chairs extends JavaPlugin {
|
|||||||
notifyplayer = getConfig().getBoolean("notify-player");
|
notifyplayer = getConfig().getBoolean("notify-player");
|
||||||
invertedStairCheck = getConfig().getBoolean("upside-down-check");
|
invertedStairCheck = getConfig().getBoolean("upside-down-check");
|
||||||
invertedStepCheck = getConfig().getBoolean("upper-step-check");
|
invertedStepCheck = getConfig().getBoolean("upper-step-check");
|
||||||
ignoreIfBlockInHand = getConfig().getBoolean("ignore-if-block-in-hand");
|
ignoreIfBlockInHand = getConfig().getBoolean("ignore-if-item-in-hand");
|
||||||
|
|
||||||
|
disabledRegions = new HashSet<String>(getConfig().getStringList("disabledRegions"));
|
||||||
|
|
||||||
sitEffectsEnabled = getConfig().getBoolean("sit-effects.enabled", false);
|
sitEffectsEnabled = getConfig().getBoolean("sit-effects.enabled", false);
|
||||||
sitEffectInterval = getConfig().getInt("sit-effects.interval",20);
|
sitEffectInterval = getConfig().getInt("sit-effects.interval",20);
|
||||||
@ -289,17 +292,6 @@ public class Chairs extends JavaPlugin {
|
|||||||
logError(e.getMessage());
|
logError(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<String> perms = new ArrayList<String>();
|
|
||||||
perms.add("chairs.sit");
|
|
||||||
perms.add("chairs.reload");
|
|
||||||
perms.add("chairs.self");
|
|
||||||
perms.add("chairs.sit.health");
|
|
||||||
for (String s : perms) {
|
|
||||||
if (pm.getPermission(s) != null) {
|
|
||||||
pm.removePermission(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logInfo(String _message) {
|
public void logInfo(String _message) {
|
||||||
|
@ -205,6 +205,12 @@ public class EventListener implements Listener {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//region allowance check
|
||||||
|
if (!WGHook.isAllowedInRegion(plugin.disabledRegions, block.getLocation()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
27
src/com/cnaude/chairs/WGHook.java
Normal file
27
src/com/cnaude/chairs/WGHook.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package com.cnaude.chairs;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||||
|
import com.sk89q.worldguard.bukkit.WGBukkit;
|
||||||
|
|
||||||
|
public class WGHook {
|
||||||
|
|
||||||
|
public static boolean isAllowedInRegion(HashSet<String> disabledRegions, Location location) {
|
||||||
|
try {
|
||||||
|
if (disabledRegions.isEmpty()) {return true;}
|
||||||
|
|
||||||
|
List<String> aregions = WGBukkit.getRegionManager(location.getWorld()).getApplicableRegionsIDs(BukkitUtil.toVector(location));
|
||||||
|
for (String region : aregions) {
|
||||||
|
if (disabledRegions.contains(region)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -13,7 +13,7 @@
|
|||||||
# upper-step-check: If true then prevent players from sitting on an upper slab.
|
# upper-step-check: If true then prevent players from sitting on an upper slab.
|
||||||
# seat-occupied-check: Check if seat is already occupied.
|
# seat-occupied-check: Check if seat is already occupied.
|
||||||
# per-item-perms: Enable chairs.sit.[item] permission node. Set to false if you're sitting on every block.
|
# per-item-perms: Enable chairs.sit.[item] permission node. Set to false if you're sitting on every block.
|
||||||
# ignore-if-block-in-hand: Set this true disable sititng if player is holding a block in hand.
|
# ignore-if-item-in-hand: Set this true disable sititng if player is holding an item in hand.
|
||||||
# ------
|
# ------
|
||||||
allowed-blocks:
|
allowed-blocks:
|
||||||
- WOOD_STAIRS
|
- WOOD_STAIRS
|
||||||
@ -35,12 +35,13 @@ auto-rotate: true
|
|||||||
max-chair-width: 3
|
max-chair-width: 3
|
||||||
sign-check: false
|
sign-check: false
|
||||||
distance: 2
|
distance: 2
|
||||||
|
disabledRegions: []
|
||||||
sitting-height: 0.7
|
sitting-height: 0.7
|
||||||
sitting-height-adj: 1.0
|
sitting-height-adj: 1.0
|
||||||
notify-player: true
|
notify-player: true
|
||||||
upside-down-check: true
|
upside-down-check: true
|
||||||
upper-step-check: true
|
upper-step-check: true
|
||||||
ignore-if-block-in-hand: false
|
ignore-if-item-in-hand: false
|
||||||
sit-effects:
|
sit-effects:
|
||||||
enabled: false
|
enabled: false
|
||||||
interval: 20
|
interval: 20
|
||||||
|
Loading…
Reference in New Issue
Block a user