Protect entities from endercrystal explosions using explosionFlagCancellation setting.

Should be more consistent with other explosion flags (tnt, creepers) now.
Improves fix for WORLDGUARD-2620.
This commit is contained in:
wizjany 2016-08-24 18:22:43 -04:00
parent b2b0fe65c6
commit 9cafb07e4d

View File

@ -167,6 +167,19 @@ private void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
}
}
if (attacker.getType() == Entities.enderCrystalType) {
// this isn't handled elsewhere because ender crystal explosions don't carry a player cause
// in the same way that creepers or tnt can
WorldConfiguration wcfg = plugin.getGlobalStateManager().get(defender.getWorld());
if (wcfg.useRegions && wcfg.explosionFlagCancellation) {
if (!plugin.getRegionContainer().createQuery().getApplicableRegions(defender.getLocation())
.testState(null, DefaultFlag.OTHER_EXPLOSION)) {
event.setCancelled(true);
return;
}
}
}
if (defender instanceof Player) {
Player player = (Player) defender;
LocalPlayer localPlayer = plugin.wrapPlayer(player);