Fix TNT explosions: refactoring
This commit is contained in:
parent
055ab7dd90
commit
8e20b66307
@ -207,20 +207,21 @@ public class FactionsEntityListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onEntityExplode(EntityExplodeEvent event) {
|
public void onEntityExplode(EntityExplodeEvent event) {
|
||||||
|
Entity boomer = event.getEntity();
|
||||||
|
|
||||||
// Before we need to check the location where the block is placed
|
// 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);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity boomer = event.getEntity();
|
// Loop the blocklist to run checks on each aimed block
|
||||||
Iterator<Block> blockList = event.blockList().iterator();
|
Iterator<Block> blockList = event.blockList().iterator();
|
||||||
|
|
||||||
// Loop the blocklist to run checks on each aimed block
|
|
||||||
while (blockList.hasNext()) {
|
while (blockList.hasNext()) {
|
||||||
Block block = blockList.next();
|
Block block = blockList.next();
|
||||||
|
|
||||||
if (!this.checkExplosionForBlock(event, block)) {
|
if (!this.checkExplosionForBlock(boomer, block)) {
|
||||||
// The block don't have to explode
|
// The block don't have to explode
|
||||||
blockList.remove();
|
blockList.remove();
|
||||||
}
|
}
|
||||||
@ -257,8 +258,7 @@ public class FactionsEntityListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkExplosionForBlock(EntityExplodeEvent event, Block block) {
|
private boolean checkExplosionForBlock(Entity boomer, Block block) {
|
||||||
Entity boomer = event.getEntity();
|
|
||||||
Faction faction = Board.getInstance().getFactionAt(new FLocation(block.getLocation()));
|
Faction faction = Board.getInstance().getFactionAt(new FLocation(block.getLocation()));
|
||||||
|
|
||||||
if (faction.noExplosionsInTerritory() || (faction.isPeaceful() && Conf.peacefulTerritoryDisableBoom)) {
|
if (faction.noExplosionsInTerritory() || (faction.isPeaceful() && Conf.peacefulTerritoryDisableBoom)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user