From cbd427f561f2f2f3f168d07044dca72d02fdb133 Mon Sep 17 00:00:00 2001 From: Phoenix616 Date: Wed, 24 Jun 2020 16:00:16 +0100 Subject: [PATCH] Cancel left click event on shop sign This should improve compatibility with other plugins that handle left click interactions too and shouldn't apply to shop signs you don't have access to. Also includes a small improvement to not run the same permission check twice in certain cases. --- .../Acrobot/ChestShop/Listeners/Player/PlayerInteract.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 dc18afc..9117149 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerInteract.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerInteract.java @@ -42,7 +42,6 @@ import static com.Acrobot.ChestShop.Events.TransactionEvent.TransactionType; import static com.Acrobot.ChestShop.Events.TransactionEvent.TransactionType.BUY; import static com.Acrobot.ChestShop.Events.TransactionEvent.TransactionType.SELL; import static com.Acrobot.ChestShop.Permission.OTHER_NAME_CREATE; -import static com.Acrobot.ChestShop.Permission.OTHER_NAME_DESTROY; import static com.Acrobot.ChestShop.Signs.ChestShopSign.*; import static org.bukkit.event.block.Action.LEFT_CLICK_BLOCK; import static org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK; @@ -118,7 +117,7 @@ public class PlayerInteract implements Listener { if (Properties.IGNORE_ACCESS_PERMS || ChestShopSign.isOwner(player, sign)) { if (Properties.ALLOW_SIGN_CHEST_OPEN && !(Properties.IGNORE_CREATIVE_MODE && player.getGameMode() == GameMode.CREATIVE)) { if (player.isSneaking() || player.isInsideVehicle() - || (Properties.ALLOW_LEFT_CLICK_DESTROYING && action == LEFT_CLICK_BLOCK && ChestShopSign.hasPermission(player, OTHER_NAME_DESTROY, sign))) { + || (Properties.ALLOW_LEFT_CLICK_DESTROYING && action == LEFT_CLICK_BLOCK)) { return; } event.setCancelled(true); @@ -132,6 +131,8 @@ public class PlayerInteract implements Listener { if (action == RIGHT_CLICK_BLOCK) { event.setCancelled(true); + } else if (action == LEFT_CLICK_BLOCK && !ChestShopSign.canAccess(player, sign)) { + event.setCancelled(true); } if (Properties.CHECK_ACCESS_FOR_SHOP_USE && !Security.canAccess(player, block, true)) {