New conf.json option "safeZonePreventAllDamageToPlayers" (default false) which will prevent all damage to players while they're in a Safe Zone; note that attack damage from other players and monsters is still prevented regardless

This commit is contained in:
Brettflan 2011-07-29 06:39:20 -05:00
parent e3cb829e6b
commit 63ab41f933
2 changed files with 21 additions and 8 deletions

View File

@ -99,6 +99,7 @@ public class Conf {
public static boolean safeZoneDenyBuild = true;
public static boolean safeZoneDenyUseage = true;
public static boolean safeZoneBlockTNT = true;
public static boolean safeZonePreventAllDamageToPlayers = false;
public static boolean warZoneDenyBuild = true;
public static boolean warZoneDenyUseage = true;

View File

@ -82,10 +82,12 @@ public class FactionsEntityListener extends EntityListener {
if ( ! this.canDamagerHurtDamagee(sub)) {
event.setCancelled(true);
}
} else if (Conf.safeZonePreventAllDamageToPlayers && isPlayerInSafeZone(event.getEntity())) {
// Players can not take any damage in a Safe Zone
event.setCancelled(true);
}
}
@Override
public void onEntityExplode(EntityExplodeEvent event)
{
@ -126,6 +128,16 @@ public class FactionsEntityListener extends EntityListener {
}
}
public boolean isPlayerInSafeZone(Entity damagee) {
if ( ! (damagee instanceof Player)) {
return false;
}
if (Board.getFactionAt(new FLocation(damagee.getLocation())).isSafeZone()) {
return true;
}
return false;
}
public boolean canDamagerHurtDamagee(EntityDamageByEntityEvent sub) {
Entity damager = sub.getDamager();
Entity damagee = sub.getEntity();