From 35628d09beb981ac838267aee48d05a67a1fc28c Mon Sep 17 00:00:00 2001 From: sk89q Date: Sun, 4 Nov 2012 12:17:05 -0800 Subject: [PATCH] Route BlockDispenseEvent to RuleLists item-drop. --- .../bukkit/WorldGuardBlockListener.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardBlockListener.java b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardBlockListener.java index 21f102b2..0b77ad5e 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardBlockListener.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardBlockListener.java @@ -34,6 +34,7 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockDamageEvent; +import org.bukkit.event.block.BlockDispenseEvent; import org.bukkit.event.block.BlockFadeEvent; import org.bukkit.event.block.BlockFormEvent; import org.bukkit.event.block.BlockFromToEvent; @@ -728,4 +729,20 @@ public void onBlockPistonRetract(BlockPistonRetractEvent event) { } } } + + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void onBlockDispense(BlockDispenseEvent event) { + ConfigurationManager cfg = plugin.getGlobalStateManager(); + WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld()); + + // RuleLists + RuleSet rules = wcfg.getRuleList().get(KnownAttachment.ITEM_DROP); + BukkitContext context = new BukkitContext(event); + context.setSourceBlock(event.getBlock().getState()); + context.setItem(event.getItem()); + if (rules.process(context)) { + event.setCancelled(true); + return; + } + } }