diff --git a/src/main/java/com/sk89q/worldguard/bukkit/WorldConfiguration.java b/src/main/java/com/sk89q/worldguard/bukkit/WorldConfiguration.java index 48a22a95..3107489b 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/WorldConfiguration.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/WorldConfiguration.java @@ -182,6 +182,7 @@ public class WorldConfiguration { public boolean disableObsidianGenerators; public boolean strictEntitySpawn; public TargetMatcherSet allowAllInteract; + public TargetMatcherSet blockUseAtFeet; private Map maxRegionCounts; @@ -346,6 +347,7 @@ private void loadConfiguration() { strictEntitySpawn = getBoolean("event-handling.block-entity-spawns-with-untraceable-cause", false); allowAllInteract = getTargetMatchers("event-handling.interaction-whitelist"); + blockUseAtFeet = getTargetMatchers("event-handling.emit-block-use-at-feet"); itemDurability = getBoolean("protection.item-durability", true); removeInfiniteStacks = getBoolean("protection.remove-infinite-stacks", false); 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 e0f0ce4a..f0304da4 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java @@ -392,6 +392,16 @@ public void onPlayerInteract(PlayerInteractEvent event) { event.setUseItemInHand(Result.DENY); } + // Check for items that the administrator has configured to + // emit a "use block here" event where the player is + // standing, which is a hack to protect items that don't + // throw events + if (item != null && getWorldConfig(player.getWorld()).blockUseAtFeet.test(item)) { + if (Events.fireAndTestCancel(new UseBlockEvent(event, cause, player.getLocation().getBlock()))) { + event.setCancelled(true); + } + } + break; } }