From e54cf242484454b216cdc71a6e6dec5ae6bac932 Mon Sep 17 00:00:00 2001 From: Traks Date: Wed, 18 Dec 2019 19:42:57 +0100 Subject: [PATCH] Fix interact handling for sneaking players --- .../bukkit/listeners/PlayerEvents.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java index 740cb8155..3a1e9e8de 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java @@ -1925,13 +1925,21 @@ import java.util.regex.Pattern; case RIGHT_CLICK_BLOCK: { Material blockType = block.getType(); eventType = PlayerBlockEventType.INTERACT_BLOCK; - if (blockType.isInteractable() && player.isSneaking()) { - return; //this returns so the block place event is called - } blocktype1 = BukkitAdapter.asBlockType(block.getType()); - if (!player.isSneaking()) { - break; + + if (blockType.isInteractable()) { + if (!player.isSneaking()) { + break; + } + ItemStack hand = player.getInventory().getItemInMainHand(); + ItemStack offHand = player.getInventory().getItemInOffHand(); + + // sneaking players interact with blocks if both hands are empty + if (hand.getType() == Material.AIR && offHand.getType() == Material.AIR) { + break; + } } + Material type = event.getMaterial(); // in the following, lb needs to have the material of the item in hand i.e. type