@Override
public void onEntityDamage(EntityDamageEvent event)
{
if (!event.isCancelled())
{
Entity e = event.getEntity();
EpicZone sancZone = General.GetZoneForPlayer(null, e.getLocation().getWorld().getName(), e.getLocation().getBlockY(), new Point(e.getLocation().getBlockX(), e.getLocation().getBlockZ()));
if ((sancZone != null && !sancZone.getSanctuary()) || sancZone == null)
{
if (event.getCause() == DamageCause.ENTITY_ATTACK)
{
if (event instanceof EntityDamageByEntityEvent)
{
EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) event;
if (isPlayer(sub.getEntity()) && isPlayer(sub.getDamager()))
{
Player player = (Player) sub.getEntity();
EpicZonePlayer ezp = General.getPlayer(player.getName());
EpicZone zone = ezp.getCurrentZone();
if (zone != null)
{
if (!zone.getPVP())
{
event.setCancelled(true);
}
}
else
{
if (!General.myGlobalZones.get(e.getWorld().getName().toLowerCase()).getPVP())
{
event.setCancelled(true);
}
}
}
else if (sub.getDamager().toString().equalsIgnoreCase("CraftGhast"))
{
if (sancZone != null)
{
if (!sancZone.getExplode().getGhast())
{
event.setCancelled(true);
}
}
}
}
}
else if (event.getCause() == DamageCause.BLOCK_EXPLOSION)
{
if (sancZone != null)
{
if (!sancZone.getExplode().getTNT())
{
event.setCancelled(true);
}
}
}
else if (event.getCause() == DamageCause.ENTITY_EXPLOSION)
{
if (sancZone != null)
{
if (!sancZone.getExplode().getCreeper())
{
event.setCancelled(true);
}
}
}
else if (event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK)
{
if (sancZone != null)
{
if (!sancZone.getFire().getIgnite())
{
if (isPlayer(e))
{
e.setFireTicks(0);
event.setCancelled(true);
}
else if (!sancZone.getFireBurnsMobs())
{
e.setFireTicks(0);
event.setCancelled(true);
}
}
}
}
}
else //This is a sanctuary zone, no damage allowed to players.
{
if (isPlayer(e))
{
e.setFireTicks(0);
event.setCancelled(true);
}
}
}
}