Added a config option to allow explosion flags to only prevent block

damage
This commit is contained in:
Dark Arc 2013-09-11 19:07:20 -04:00
parent e26238e814
commit faa016180a
2 changed files with 12 additions and 10 deletions

View File

@ -166,6 +166,7 @@ public class WorldConfiguration {
public boolean disableSoilDehydration;
public Set<Integer> allowedSnowFallOver;
public boolean regionInvinciblityRemovesMobs;
public boolean explosionFlagCancellation;
public boolean disableDeathMessages;
public boolean disableObsidianGenerators;
@ -410,6 +411,7 @@ private void loadConfiguration() {
useRegions = getBoolean("regions.enable", true);
regionInvinciblityRemovesMobs = getBoolean("regions.invincibility-removes-mobs", false);
explosionFlagCancellation = getBoolean("regions.explosion-flags-block-entity-damage", true);
highFreqFlags = getBoolean("regions.high-frequency-flags", false);
regionWand = getInt("regions.wand", 334);
maxClaimVolume = getInt("regions.max-claim-volume", 30000);

View File

@ -291,7 +291,7 @@ private void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
event.setCancelled(true);
return;
}
if (wcfg.useRegions) {
if (wcfg.useRegions && wcfg.explosionFlagCancellation) {
Vector pt = toVector(defender.getLocation());
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
@ -327,7 +327,7 @@ private void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
tryCancelPVPEvent((Player) fireball.getShooter(), player, event, false);
}
} else {
if (!set.allows(DefaultFlag.GHAST_FIREBALL, localPlayer)) {
if (!set.allows(DefaultFlag.GHAST_FIREBALL, localPlayer) && wcfg.explosionFlagCancellation) {
event.setCancelled(true);
return;
}
@ -358,7 +358,7 @@ private void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
}
if (attacker instanceof Creeper) {
if (!set.allows(DefaultFlag.CREEPER_EXPLOSION, localPlayer)) {
if (!set.allows(DefaultFlag.CREEPER_EXPLOSION, localPlayer) && wcfg.explosionFlagCancellation) {
event.setCancelled(true);
return;
}
@ -406,7 +406,7 @@ private void onEntityDamageByProjectile(EntityDamageByEntityEvent event) {
}
// Check Mob
if (attacker != null && attacker instanceof LivingEntity && !(attacker instanceof Player)) {
if (attacker != null && !(attacker instanceof Player)) {
if (wcfg.disableMobDamage) {
event.setCancelled(true);
return;
@ -591,7 +591,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
for (Block block : event.blockList()) {
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.CREEPER_EXPLOSION)) {
event.blockList().clear();
event.setCancelled(true);
if (wcfg.explosionFlagCancellation) event.setCancelled(true);
return;
}
}
@ -599,7 +599,6 @@ public void onEntityExplode(EntityExplodeEvent event) {
} else if (ent instanceof EnderDragon) {
if (wcfg.blockEnderDragonBlockDamage) {
event.blockList().clear();
event.setCancelled(true);
return;
}
@ -609,7 +608,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
for (Block block : event.blockList()) {
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.ENDERDRAGON_BLOCK_DAMAGE)) {
event.blockList().clear();
event.setCancelled(true);
if (wcfg.explosionFlagCancellation) event.setCancelled(true);
return;
}
}
@ -630,7 +629,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
for (Block block : event.blockList()) {
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.TNT)) {
event.blockList().clear();
event.setCancelled(true);
if (wcfg.explosionFlagCancellation) event.setCancelled(true);
return;
}
}
@ -662,7 +661,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
for (Block block : event.blockList()) {
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.GHAST_FIREBALL)) {
event.blockList().clear();
event.setCancelled(true);
if (wcfg.explosionFlagCancellation) event.setCancelled(true);
return;
}
}
@ -686,7 +685,8 @@ public void onEntityExplode(EntityExplodeEvent event) {
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
for (Block block : event.blockList()) {
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.OTHER_EXPLOSION)) {
event.setCancelled(true);
event.blockList().clear();
if (wcfg.explosionFlagCancellation) event.setCancelled(true);
return;
}
}