Route BlockDispenseEvent to RuleLists item-drop.

This commit is contained in:
sk89q 2012-11-04 12:17:05 -08:00
parent ef43ba2700
commit 35628d09be

View File

@ -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;
}
}
}