Skip to content

Commit

Permalink
Handle dispenser redstone event
Browse files Browse the repository at this point in the history
  • Loading branch information
pop4959 committed Feb 8, 2024
1 parent 4cfd25d commit 184cb1c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/main/java/com/griefcraft/listeners/LWCBlockListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 184cb1c

Please sign in to comment.