From 184cb1ce7f9ee44cfdd9dbb0bc8d1ee543ac7466 Mon Sep 17 00:00:00 2001 From: Christopher Bohn Date: Thu, 8 Feb 2024 01:04:35 -0800 Subject: [PATCH] Handle dispenser redstone event --- .../listeners/LWCBlockListener.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) 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) {