mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-08 03:49:32 +01:00
Adds null check in EntityExplodeEvent's handler, fixing WORLDGUARD-2267.
This commit is contained in:
parent
47902e1177
commit
1ba7d623b4
@ -496,108 +496,111 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ent.getType() == witherType) {
|
// Not all explosions come from an entity
|
||||||
if (wcfg.blockWitherBlockDamage) {
|
if (ent != null) {
|
||||||
event.blockList().clear();
|
if (ent.getType() == witherType) {
|
||||||
return;
|
if (wcfg.blockWitherBlockDamage) {
|
||||||
|
event.blockList().clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wcfg.blockWitherExplosions) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wcfg.blockWitherExplosions) {
|
if (ent.getType() == witherSkullType) {
|
||||||
event.setCancelled(true);
|
if (wcfg.blockWitherSkullBlockDamage) {
|
||||||
return;
|
event.blockList().clear();
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ent.getType() == witherSkullType) {
|
if (wcfg.blockWitherSkullExplosions) {
|
||||||
if (wcfg.blockWitherSkullBlockDamage) {
|
event.setCancelled(true);
|
||||||
event.blockList().clear();
|
return;
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wcfg.blockWitherSkullExplosions) {
|
if (ent instanceof Creeper) {
|
||||||
event.setCancelled(true);
|
if (wcfg.blockCreeperBlockDamage) {
|
||||||
return;
|
event.blockList().clear();
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ent instanceof Creeper) {
|
if (wcfg.blockCreeperExplosions) {
|
||||||
if (wcfg.blockCreeperBlockDamage) {
|
event.setCancelled(true);
|
||||||
event.blockList().clear();
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (wcfg.blockCreeperExplosions) {
|
if (wcfg.useRegions) {
|
||||||
event.setCancelled(true);
|
if (wcfg.useRegions) {
|
||||||
return;
|
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||||
}
|
|
||||||
|
for (Block block : event.blockList()) {
|
||||||
|
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.CREEPER_EXPLOSION)) {
|
||||||
|
event.blockList().clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (ent instanceof EnderDragon) {
|
||||||
|
if (wcfg.blockEnderDragonBlockDamage) {
|
||||||
|
event.blockList().clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (wcfg.useRegions) {
|
|
||||||
if (wcfg.useRegions) {
|
if (wcfg.useRegions) {
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||||
|
|
||||||
for (Block block : event.blockList()) {
|
for (Block block : event.blockList()) {
|
||||||
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.CREEPER_EXPLOSION)) {
|
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.ENDERDRAGON_BLOCK_DAMAGE)) {
|
||||||
event.blockList().clear();
|
event.blockList().clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (ent instanceof TNTPrimed) {
|
||||||
} else if (ent instanceof EnderDragon) {
|
if (wcfg.blockTNTBlockDamage) {
|
||||||
if (wcfg.blockEnderDragonBlockDamage) {
|
event.blockList().clear();
|
||||||
event.blockList().clear();
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (wcfg.useRegions) {
|
if (wcfg.blockTNTExplosions) {
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (Block block : event.blockList()) {
|
if (wcfg.useRegions) {
|
||||||
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.ENDERDRAGON_BLOCK_DAMAGE)) {
|
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||||
event.blockList().clear();
|
|
||||||
return;
|
for (Block block : event.blockList()) {
|
||||||
|
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.TNT)) {
|
||||||
|
event.blockList().clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (ent instanceof Fireball) {
|
||||||
} else if (ent instanceof TNTPrimed) {
|
if (wcfg.blockFireballBlockDamage) {
|
||||||
if (wcfg.blockTNTBlockDamage) {
|
event.blockList().clear();
|
||||||
event.blockList().clear();
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wcfg.blockTNTExplosions) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wcfg.useRegions) {
|
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
|
||||||
|
|
||||||
for (Block block : event.blockList()) {
|
|
||||||
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.TNT)) {
|
|
||||||
event.blockList().clear();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else if (ent instanceof Fireball) {
|
|
||||||
if (wcfg.blockFireballBlockDamage) {
|
|
||||||
event.blockList().clear();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wcfg.blockFireballExplosions) {
|
if (wcfg.blockFireballExplosions) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wcfg.useRegions) {
|
if (wcfg.useRegions) {
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||||
|
|
||||||
for (Block block : event.blockList()) {
|
for (Block block : event.blockList()) {
|
||||||
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.GHAST_FIREBALL)) {
|
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.GHAST_FIREBALL)) {
|
||||||
event.blockList().clear();
|
event.blockList().clear();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -628,7 +631,7 @@ public void onExplosionPrime(ExplosionPrimeEvent event) {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getEntityType() == witherType) {
|
if (event.getEntityType() == witherType) {
|
||||||
if (wcfg.blockWitherExplosions) {
|
if (wcfg.blockWitherExplosions) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -788,7 +791,7 @@ public void onEndermanPickup(EntityChangeBlockEvent event) {
|
|||||||
} else if (ent.getType() == witherType) {
|
} else if (ent.getType() == witherType) {
|
||||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||||
WorldConfiguration wcfg = cfg.get(ent.getWorld());
|
WorldConfiguration wcfg = cfg.get(ent.getWorld());
|
||||||
|
|
||||||
if (wcfg.blockWitherBlockDamage || wcfg.blockWitherExplosions) {
|
if (wcfg.blockWitherBlockDamage || wcfg.blockWitherExplosions) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user