Make my own ZONE

Santiago

Новичок
#1
Hello, i wonder to know if is possible make my own zone, for example in L2jServer you can make your own zone with two Java classes.

1. The Java file
JavaScript:
public class L2CustomZone extends L2ZoneType
{
    private String zoneName;
    private boolean isFlyingEnable;
    
    public L2CustomZone(final int id)
    {
        super(id);
        isFlyingEnable = true;
    }
    
    @Override
    protected void onDieInside(final L2Character l2character)
    {
    }
    
    @Override
    protected void onReviveInside(final L2Character l2character)
    {
    }
    
    @Override
    public void setParameter(final String name, final String value)
    {
        switch (name)
        {
            case "name":
                zoneName = value;
                break;
            case "flying":
                isFlyingEnable = Boolean.parseBoolean(value);
                break;
            default:
                super.setParameter(name, value);
                break;
        }
    }
    
    @Override
    protected void onEnter(final L2Character character)
    {
        if (character instanceof L2PcInstance)
        {
            final L2PcInstance player = (L2PcInstance) character;
            if (!player.isGM() && player.isFlying() && !player.isInJail() && !isFlyingEnable)
            {
                player.teleToLocation(com.l2jfrozen.gameserver.datatables.csv.MapRegionTable.TeleportWhereType.Town);
            }
            
            if (zoneName.equalsIgnoreCase("tradeoff"))
            {
                player.sendMessage("Trade restrictions are involved.");
                player.setTradeDisabled(true);
            }
        }
    }
    
    @Override
    protected void onExit(final L2Character character)
    {
        if (character instanceof L2PcInstance)
        {
            final L2PcInstance player = (L2PcInstance) character;
            
            if (zoneName.equalsIgnoreCase("tradeoff"))
            {
                player.sendMessage("Trade restrictions removed.");
                player.setTradeDisabled(false);
            }
        }
    }
    
    public String getZoneName()
    {
        return zoneName;
    }
    
    public boolean isFlyingEnable()
    {
        return isFlyingEnable;
    }
}
2. Registering the zone to be loaded (Giving an example)
Код:
case "CustomZone":
    temp = new L2CustomZone(zoneId);
    break;

zones.put(zoneId, temp);
Of course the ID, name and shape zone giving XML file.

Код:
  <zone id="12000" type="CustomZone" shape="Cuboid" minZ="-5000" maxZ="5000">
    <node X="43084" Y="15944" />
    <node X="45140" Y="15816" />
    <node X="45748" Y="17200" />
    <node X="44504" Y="18780" />
    <node X="43284" Y="18952" />
    <node X="42476" Y="18164" />
    <node X="42480" Y="16448" />
    <stat name="name" val="TradeOff"/>
  </zone>
Since Lucera V2 dont need to specify id. I wonder to know how i can make my own zone with my own rules o procedures using the extension.
 
Вверх