Skip to content
Permalink
Browse files

Handle BlockExplodeEvent as other explosion.

Also misc cleanup.
Closes #407, WORLDGUARD-3843.
  • Loading branch information...
wizjany authored and DarkArc committed May 12, 2019
1 parent f76259d commit d296e6e4292058e7e880a54e6e4dff6ad1e5c16e
@@ -880,6 +880,14 @@ public void onBlockDispense(BlockDispenseEvent event) {
}
}

@EventHandler(ignoreCancelled = true)
public void onBlockExplode(BlockExplodeEvent event) {
final BreakBlockEvent eventToFire = new BreakBlockEvent(event, create(event.getBlock()),
event.getBlock().getLocation().getWorld(), event.blockList(), Material.AIR);
eventToFire.getRelevantFlags().add(DefaultFlag.OTHER_EXPLOSION);
Events.fireBulkEventToCancel(event, eventToFire);
}

/**
* Handle the right click of a block while an item is held.
*
@@ -37,6 +37,7 @@
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockExplodeEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.block.BlockFromToEvent;
@@ -664,4 +665,19 @@ public void onBlockFade(BlockFadeEvent event) {

}

@EventHandler(ignoreCancelled = true)
public void onBlockExplode(BlockExplodeEvent event) {
ConfigurationManager cfg = plugin.getGlobalStateManager();

if (cfg.activityHaltToggle) {
event.setCancelled(true);
return;
}

WorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());
if (wcfg.blockOtherExplosions) {
event.setCancelled(true);
}
}

}
@@ -410,9 +410,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
Entity ent = event.getEntity();

if (cfg.activityHaltToggle) {
if (ent != null) {
ent.remove();
}
ent.remove();
event.setCancelled(true);
return;
}

0 comments on commit d296e6e

Please sign in to comment.
You can’t perform that action at this time.