Added config option to disable mob damage for people not using regions

This commit is contained in:
Wizjany 2011-06-15 13:02:59 -04:00
parent 4ad8d362f7
commit 6496bbd87f
3 changed files with 12 additions and 0 deletions

View File

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

View File

@ -218,6 +218,11 @@ private void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
return; return;
} }
if (wcfg.disableMobDamage) {
event.setCancelled(true);
return;
}
if (wcfg.useRegions) { if (wcfg.useRegions) {
Vector pt = toVector(defender.getLocation()); Vector pt = toVector(defender.getLocation());
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld()); RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());
@ -273,6 +278,10 @@ private void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) {
} }
} }
if (attacker != null && attacker instanceof Skeleton) { if (attacker != null && attacker instanceof Skeleton) {
if (wcfg.disableMobDamage) {
event.setCancelled(true);
return;
}
if (wcfg.useRegions) { if (wcfg.useRegions) {
Vector pt = toVector(defender.getLocation()); Vector pt = toVector(defender.getLocation());
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld()); RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());

View File

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