Added config option to disable explosion-caused damage to players.

This commit is contained in:
Wizjany 2011-05-23 22:23:42 -04:00
parent 424b580eb9
commit 4850bdefdf
3 changed files with 12 additions and 0 deletions

View File

@ -93,6 +93,7 @@ public class WorldConfiguration {
public boolean teleportOnSuffocation;
public boolean disableVoidDamage;
public boolean teleportOnVoid;
public boolean disableExplosionDamage;
public boolean useRegions;
public boolean highFreqFlags;
public int regionWand = 287;
@ -194,6 +195,7 @@ private void loadConfiguration() {
teleportOnSuffocation = config.getBoolean("player-damage.teleport-on-suffocation", false);
disableVoidDamage = config.getBoolean("player-damage.disable-void-damage", false);
teleportOnVoid = config.getBoolean("player-damage.teleport-on-void-falling", false);
disableExplosionDamage = config.getBoolean("player-damage.disable-explosion-damage", false);
signChestProtection = config.getBoolean("chest-protection.enable", false);

View File

@ -128,6 +128,10 @@ public void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
return;
}
if (wcfg.disableExplosionDamage && event.getCause() == DamageCause.BLOCK_EXPLOSION) {
event.setCancelled(true);
return;
}
}
}
@ -151,6 +155,11 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
return;
}
if (wcfg.disableExplosionDamage && event.getCause() == DamageCause.ENTITY_EXPLOSION) {
event.setCancelled(true);
return;
}
if (attacker != null && attacker instanceof Player) {
if (wcfg.useRegions) {
Vector pt = toVector(defender.getLocation());

View File

@ -81,6 +81,7 @@ player-damage:
teleport-on-suffocation: off
disable-void-damage: off
teleport-on-void-falling: off
disable-explosion-damage: off
regions:
enable: on