From 7da10198e3536d17bb7e6a70e161e86b9f43c605 Mon Sep 17 00:00:00 2001 From: sk89q Date: Sun, 4 Jan 2015 18:05:50 -0800 Subject: [PATCH] Expand interaction whitelist to "physical" events. Closes WORLDGUARD-3238. --- .../listener/EventAbstractionListener.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java b/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java index 71dc37bf..7c6f6766 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java @@ -346,7 +346,9 @@ public void onPlayerInteract(PlayerInteractEvent event) { silent = true; } - interactDebounce.debounce(clicked, event.getPlayer(), event, DelegateEvents.setSilent(new UseBlockEvent(event, cause, clicked), silent)); + if (!hasInteractBypass(clicked)) { + interactDebounce.debounce(clicked, event.getPlayer(), event, DelegateEvents.setSilent(new UseBlockEvent(event, cause, clicked), silent)); + } break; case RIGHT_CLICK_BLOCK: @@ -408,7 +410,9 @@ public void onPlayerInteract(PlayerInteractEvent event) { @EventHandler(ignoreCancelled = true) public void onEntityInteract(org.bukkit.event.entity.EntityInteractEvent event) { - interactDebounce.debounce(event.getBlock(), event.getEntity(), event, new UseBlockEvent(event, create(event.getEntity()), event.getBlock())); + if (!hasInteractBypass(event.getBlock())) { + interactDebounce.debounce(event.getBlock(), event.getEntity(), event, new UseBlockEvent(event, create(event.getEntity()), event.getBlock())); + } } @EventHandler(ignoreCancelled = true) @@ -874,14 +878,22 @@ private static void handleInventoryHolderUse(T o } } + private boolean hasInteractBypass(Block block) { + return getWorldConfig(block.getWorld()).allowAllInteract.test(block); + } + + private boolean hasInteractBypass(World world, ItemStack item) { + return getWorldConfig(world).allowAllInteract.test(item); + } + private boolean isBlockModifiedOnClick(Block block) { - return Materials.isBlockModifiedOnClick(block.getType()) && !getWorldConfig(block.getWorld()).allowAllInteract.test(block); + return Materials.isBlockModifiedOnClick(block.getType()) && !hasInteractBypass(block); } private boolean isItemAppliedToBlock(ItemStack item, Block clicked) { return Materials.isItemAppliedToBlock(item.getType(), clicked.getType()) - && !getWorldConfig(clicked.getWorld()).allowAllInteract.test(clicked) - && !getWorldConfig(clicked.getWorld()).allowAllInteract.test(item); + && !hasInteractBypass(clicked) + && !hasInteractBypass(clicked.getWorld(), item); } private void playDenyEffect(Player player, Location location) {