diff --git a/libs/WorldEdit.jar b/libs/WorldEdit.jar new file mode 100644 index 0000000..fa48dfa Binary files /dev/null and b/libs/WorldEdit.jar differ diff --git a/libs/WorldGuard.jar b/libs/WorldGuard.jar new file mode 100644 index 0000000..d585c14 Binary files /dev/null and b/libs/WorldGuard.jar differ diff --git a/src/com/cnaude/chairs/Chairs.java b/src/com/cnaude/chairs/Chairs.java index 962138c..3eb77e7 100644 --- a/src/com/cnaude/chairs/Chairs.java +++ b/src/com/cnaude/chairs/Chairs.java @@ -28,7 +28,7 @@ import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolManager; public class Chairs extends JavaPlugin { - public static ChairEffects chairEffects; + public ChairEffects chairEffects; public List allowedBlocks; public List validSigns; public boolean autoRotate, signCheck, notifyplayer; @@ -39,11 +39,12 @@ public class Chairs extends JavaPlugin { public int sitMaxHealth; public int sitHealthPerInterval; public int sitEffectInterval; + public HashSet disabledRegions = new HashSet(); private File pluginFolder; private File configFile; private Logger log; public PluginManager pm; - public static ChairsIgnoreList ignoreList; + public ChairsIgnoreList ignoreList; public String msgSitting, msgStanding, msgOccupied, msgNoPerm, msgReloaded, msgDisabled, msgEnabled; private ProtocolManager protocolManager; @@ -225,7 +226,9 @@ public class Chairs extends JavaPlugin { notifyplayer = getConfig().getBoolean("notify-player"); invertedStairCheck = getConfig().getBoolean("upside-down-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(getConfig().getStringList("disabledRegions")); sitEffectsEnabled = getConfig().getBoolean("sit-effects.enabled", false); sitEffectInterval = getConfig().getInt("sit-effects.interval",20); @@ -289,17 +292,6 @@ public class Chairs extends JavaPlugin { logError(e.getMessage()); } } - - ArrayList perms = new ArrayList(); - 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) { diff --git a/src/com/cnaude/chairs/EventListener.java b/src/com/cnaude/chairs/EventListener.java index c62d8c2..1c39105 100644 --- a/src/com/cnaude/chairs/EventListener.java +++ b/src/com/cnaude/chairs/EventListener.java @@ -205,6 +205,12 @@ public class EventListener implements Listener { } return false; } + + //region allowance check + if (!WGHook.isAllowedInRegion(plugin.disabledRegions, block.getLocation())) + { + return false; + } return true; } diff --git a/src/com/cnaude/chairs/WGHook.java b/src/com/cnaude/chairs/WGHook.java new file mode 100644 index 0000000..f2e09c8 --- /dev/null +++ b/src/com/cnaude/chairs/WGHook.java @@ -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 disabledRegions, Location location) { + try { + if (disabledRegions.isEmpty()) {return true;} + + List aregions = WGBukkit.getRegionManager(location.getWorld()).getApplicableRegionsIDs(BukkitUtil.toVector(location)); + for (String region : aregions) { + if (disabledRegions.contains(region)) { + return false; + } + } + } catch (Exception e) {} + return true; + } + +} diff --git a/src/config.yml b/src/config.yml index 784964e..3a3acca 100644 --- a/src/config.yml +++ b/src/config.yml @@ -13,7 +13,7 @@ # upper-step-check: If true then prevent players from sitting on an upper slab. # 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. -# 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: - WOOD_STAIRS @@ -35,12 +35,13 @@ auto-rotate: true max-chair-width: 3 sign-check: false distance: 2 +disabledRegions: [] sitting-height: 0.7 sitting-height-adj: 1.0 notify-player: true upside-down-check: true upper-step-check: true -ignore-if-block-in-hand: false +ignore-if-item-in-hand: false sit-effects: enabled: false interval: 20