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 safeZoneDenyBuild = true;
|
||||||
public static boolean safeZoneDenyUseage = true;
|
public static boolean safeZoneDenyUseage = true;
|
||||||
public static boolean safeZoneBlockTNT = true;
|
public static boolean safeZoneBlockTNT = true;
|
||||||
|
public static boolean safeZonePreventAllDamageToPlayers = false;
|
||||||
|
|
||||||
public static boolean warZoneDenyBuild = true;
|
public static boolean warZoneDenyBuild = true;
|
||||||
public static boolean warZoneDenyUseage = true;
|
public static boolean warZoneDenyUseage = true;
|
||||||
|
@ -73,19 +73,21 @@ public class FactionsEntityListener extends EntityListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event instanceof EntityDamageByEntityEvent) {
|
if (event instanceof EntityDamageByEntityEvent) {
|
||||||
EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent)event;
|
EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent)event;
|
||||||
if ( ! this.canDamagerHurtDamagee(sub)) {
|
if ( ! this.canDamagerHurtDamagee(sub)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (event instanceof EntityDamageByProjectileEvent) {
|
} else if (event instanceof EntityDamageByProjectileEvent) {
|
||||||
EntityDamageByProjectileEvent sub = (EntityDamageByProjectileEvent)event;
|
EntityDamageByProjectileEvent sub = (EntityDamageByProjectileEvent)event;
|
||||||
if ( ! this.canDamagerHurtDamagee(sub)) {
|
if ( ! this.canDamagerHurtDamagee(sub)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
} else if (Conf.safeZonePreventAllDamageToPlayers && isPlayerInSafeZone(event.getEntity())) {
|
||||||
|
// Players can not take any damage in a Safe Zone
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEntityExplode(EntityExplodeEvent event)
|
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) {
|
public boolean canDamagerHurtDamagee(EntityDamageByEntityEvent sub) {
|
||||||
Entity damager = sub.getDamager();
|
Entity damager = sub.getDamager();
|
||||||
Entity damagee = sub.getEntity();
|
Entity damagee = sub.getEntity();
|
||||||
|
Loading…
Reference in New Issue
Block a user