diff --git a/src/main/java/com/griefcraft/listeners/LWCBlockListener.java b/src/main/java/com/griefcraft/listeners/LWCBlockListener.java index 7ed99d7..d0b832b 100644 --- a/src/main/java/com/griefcraft/listeners/LWCBlockListener.java +++ b/src/main/java/com/griefcraft/listeners/LWCBlockListener.java @@ -52,6 +52,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockDispenseEvent; import org.bukkit.event.block.BlockExplodeEvent; import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.block.BlockMultiPlaceEvent; @@ -116,6 +117,29 @@ public void onBlockRedstoneChange(BlockRedstoneEvent event) { } } + @EventHandler + public void onBlockDispense(BlockDispenseEvent event) { + if (!LWC.ENABLED) { + return; + } + + LWC lwc = plugin.getLWC(); + Block block = event.getBlock(); + + Protection protection = lwc.findProtection(block.getLocation()); + + if (protection == null) { + return; + } + + LWCRedstoneEvent evt = new LWCRedstoneEvent(null, protection); + lwc.getModuleLoader().dispatchEvent(evt); + + if (evt.isCancelled()) { + event.setCancelled(true); + } + } + @EventHandler public void onStructureGrow(StructureGrowEvent event) { if (!LWC.ENABLED) {