diff --git a/src/main/java/com/Acrobot/ChestShop/Events/Protection/ProtectionCheckEvent.java b/src/main/java/com/Acrobot/ChestShop/Events/Protection/ProtectionCheckEvent.java index dc780eb..6bcc953 100644 --- a/src/main/java/com/Acrobot/ChestShop/Events/Protection/ProtectionCheckEvent.java +++ b/src/main/java/com/Acrobot/ChestShop/Events/Protection/ProtectionCheckEvent.java @@ -13,6 +13,7 @@ public class ProtectionCheckEvent extends Event { private Result result = Result.DEFAULT; private boolean ignoreBuiltInProtection = false; + private boolean checkManagement = true; private Block block; private Player player; @@ -27,10 +28,21 @@ public class ProtectionCheckEvent extends Event { this.ignoreBuiltInProtection = ignoreBuiltInProtection; } + public ProtectionCheckEvent(Block block, Player player, boolean ignoreBuiltInProtection, boolean checkManagement) { + this.block = block; + this.player = player; + this.ignoreBuiltInProtection = ignoreBuiltInProtection; + this.checkManagement = checkManagement; + } + public boolean isBuiltInProtectionIgnored() { return ignoreBuiltInProtection; } + public boolean checkCanManage() { + return checkManagement; + } + public Result getResult() { return result; } diff --git a/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerInteract.java b/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerInteract.java index 5f14640..0d018af 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerInteract.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerInteract.java @@ -67,7 +67,7 @@ public class PlayerInteract implements Listener { Sign sign = uBlock.getConnectedSign(block); if (sign != null) { - if (!Security.canAccess(player, block, Properties.TURN_OFF_DEFAULT_PROTECTION_WHEN_PROTECTED_EXTERNALLY)) { + if (!Security.canView(player, block, Properties.TURN_OFF_DEFAULT_PROTECTION_WHEN_PROTECTED_EXTERNALLY)) { if (Permission.has(player, Permission.SHOPINFO)) { ChestShop.callEvent(new ShopInfoEvent(player, sign)); event.setCancelled(true); diff --git a/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerInventory.java b/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerInventory.java index 7468139..d809a6c 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerInventory.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerInventory.java @@ -55,7 +55,7 @@ public class PlayerInventory implements Listener { boolean canAccess = false; for (Block container : containers) { if (ChestShopSign.isShopBlock(container)) { - if (Security.canAccess(player, container)) { + if (Security.canView(player, container, false)) { canAccess = true; } } else { diff --git a/src/main/java/com/Acrobot/ChestShop/Plugins/LightweightChestProtection.java b/src/main/java/com/Acrobot/ChestShop/Plugins/LightweightChestProtection.java index 123cbbc..2c56e6b 100644 --- a/src/main/java/com/Acrobot/ChestShop/Plugins/LightweightChestProtection.java +++ b/src/main/java/com/Acrobot/ChestShop/Plugins/LightweightChestProtection.java @@ -120,7 +120,9 @@ public class LightweightChestProtection implements Listener { return; } - if (!lwc.canAccessProtection(player, protection) && !protection.getType().name().equals("DONATION") && !protection.getType().name().equals("DISPLAY")) { + if (event.checkCanManage() + ? !lwc.canAdminProtection(player, protection) + : !lwc.canAccessProtection(player, protection)) { event.setResult(Event.Result.DENY); } else if (Properties.TURN_OFF_DEFAULT_PROTECTION_WHEN_PROTECTED_EXTERNALLY) { event.setResult(Event.Result.ALLOW); diff --git a/src/main/java/com/Acrobot/ChestShop/Security.java b/src/main/java/com/Acrobot/ChestShop/Security.java index 52f60a1..e75e2c7 100644 --- a/src/main/java/com/Acrobot/ChestShop/Security.java +++ b/src/main/java/com/Acrobot/ChestShop/Security.java @@ -52,6 +52,13 @@ public class Security { return event.getResult() != Event.Result.DENY; } + public static boolean canView(Player player, Block block, boolean ignoreDefaultProtection) { + ProtectionCheckEvent event = new ProtectionCheckEvent(block, player, ignoreDefaultProtection, false); + ChestShop.callEvent(event); + + return event.getResult() != Event.Result.DENY; + } + public static boolean canPlaceSign(Player player, Sign sign) { Block baseBlock = BlockUtil.getAttachedBlock(sign);