From 8e20b663075eadba777093928e6579c61a45e930 Mon Sep 17 00:00:00 2001 From: utarwyn Date: Fri, 11 May 2018 19:27:21 +0200 Subject: [PATCH] Fix TNT explosions: refactoring --- .../factions/listeners/FactionsEntityListener.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java index 63e172c5..e027a30e 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java @@ -207,20 +207,21 @@ public class FactionsEntityListener implements Listener { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onEntityExplode(EntityExplodeEvent event) { + Entity boomer = event.getEntity(); + // Before we need to check the location where the block is placed - if (!this.checkExplosionForBlock(event, event.getLocation().getBlock())) { + if (!this.checkExplosionForBlock(boomer, event.getLocation().getBlock())) { event.setCancelled(true); return; } - Entity boomer = event.getEntity(); + // Loop the blocklist to run checks on each aimed block Iterator blockList = event.blockList().iterator(); - // Loop the blocklist to run checks on each aimed block while (blockList.hasNext()) { Block block = blockList.next(); - if (!this.checkExplosionForBlock(event, block)) { + if (!this.checkExplosionForBlock(boomer, block)) { // The block don't have to explode blockList.remove(); } @@ -257,8 +258,7 @@ public class FactionsEntityListener implements Listener { } } - private boolean checkExplosionForBlock(EntityExplodeEvent event, Block block) { - Entity boomer = event.getEntity(); + private boolean checkExplosionForBlock(Entity boomer, Block block) { Faction faction = Board.getInstance().getFactionAt(new FLocation(block.getLocation())); if (faction.noExplosionsInTerritory() || (faction.isPeaceful() && Conf.peacefulTerritoryDisableBoom)) {