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:
parent
e3cb829e6b
commit
63ab41f933
@ -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;
|
||||
|
@ -73,18 +73,20 @@ public class FactionsEntityListener extends EntityListener {
|
||||
}
|
||||
|
||||
if (event instanceof EntityDamageByEntityEvent) {
|
||||
EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent)event;
|
||||
if ( ! this.canDamagerHurtDamagee(sub)) {
|
||||
EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent)event;
|
||||
if ( ! this.canDamagerHurtDamagee(sub)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (event instanceof EntityDamageByProjectileEvent) {
|
||||
EntityDamageByProjectileEvent sub = (EntityDamageByProjectileEvent)event;
|
||||
if ( ! this.canDamagerHurtDamagee(sub)) {
|
||||
} else if (event instanceof EntityDamageByProjectileEvent) {
|
||||
EntityDamageByProjectileEvent sub = (EntityDamageByProjectileEvent)event;
|
||||
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)
|
||||
@ -125,7 +127,17 @@ public class FactionsEntityListener extends EntityListener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
|
Loading…
Reference in New Issue
Block a user