public class QueenAntZone implements OnInitScriptListener
{
private static ZoneListener _zoneListener;
private final AttackListener attackListener = new AttackListener();
private final int[] check_transform_id = { 22205 }; //[TODO] [c] Может стоить сделать конфиг?
@Override
public void onInit()
{
_zoneListener = new ZoneListener();
final Zone zone = ReflectionUtils.getZone("[queen_ant_epic]");
zone.addListener(_zoneListener);
}
public class ZoneListener implements OnZoneEnterLeaveListener
{
public ZoneListener()
{}
@Override
public void onZoneEnter(final Zone zone, final Creature cha)
{
if(zone.getParams() == null || !cha.isPlayable())
return;
final Player player = cha.getPlayer();
if(zone.getParams().getBool("transformprotection"))
if(player != null)
{
player.setTransformation(0);
player.sendMessage("В данной зоне запрещено находится в трансформации!");
}
if(cha.getLevel() > zone.getParams().getInteger("levelLimit"))
if(player != null)
if(!player.isGM())
{
player.sendMessage("You have been moved to the nearest suitable location. Your level was too high.");
cha.teleToLocation(Location.parseLoc(zone.getParams().getString("teleport")));
}
else
player.sendMessage("You not teleported because you are GM!");
player.addListener(attackListener);
}
@Override
public void onZoneLeave(final Zone zone, final Creature cha)
{
if(cha.isPlayer())
cha.removeListener(attackListener);
}
}
private class AttackListener implements OnAttackListener
{
@Override
public void onAttack(final Creature actor, final Creature target)
{
if(actor.isPlayer())
{
final Player player = actor.getPlayer();
final int transform_id = player.getTransformation();
//если увидели ид трансформы которую нужно снять.
if(ArrayUtils.contains(check_transform_id, transform_id))
{
player.setTransformation(0);
player.sendMessage("Нельзя атаковать в трансформации в данной зоне!");
}
}
}
}
}