if (!DevConfig.DISABLE_ZONE_CHECK_ON_ENTER)
{
List<Zone> zones = new ArrayList<>();
World.getZones(zones, player.getLoc(), player.getReflection());
if (!zones.isEmpty())
{
for (Zone zone : zones)
{
if (zone.getType() == ZoneType.no_restart)
{
if (System.currentTimeMillis() / 1000L - player.getLastLogout() > zone.getRestartTime())
{
player.setReflection(0);
if (zone.getRestartPoints() == null)
player.setLoc(TeleportUtils.getRestartLocation(player, RestartType.TO_VILLAGE));
else
player.setLoc(zone.getSpawn(player.getKarma() < 0));
}
}
else if (zone.getType() == ZoneType.siege)
{
SiegeEvent<?, ?> siegeEvent = player.getEvent(SiegeEvent.class);
if (siegeEvent != null)
player.setLoc(siegeEvent.getEnterLoc(player));
else
{
Residence r = ResidenceHolder.getInstance().getResidence(zone.getParams().getInteger("residence"));
player.setReflection(0);
player.setLoc(r.getNotOwnerRestartPoint(player));
}
}
else if (zone.getType() == ZoneType.residence)
{
if (player.isInSiegeZone())
continue;
Residence r = (Residence) zone.getParams().getObject("residence");
if (r != null && (r.getOwner() == null || player.getClan() != r.getOwner()))
{
player.setReflection(0);
player.setLoc(r.getNotOwnerRestartPoint(player));
}
}
}
}
zones.clear();
}