Jump to content
  • 0

Question

Posted

Hi, I'm adapting the Town Manager event for aCis. 

When I change this TownManager.getTown(Config.TW_TOWN_ID).setIsTWZone(true);

 

for 

ZoneManager.getInstance().getZoneById(i, TownZone.class).setIsTWZone(true);

 

generates the error

 

GSyA0X0.png

 

what did I do wrong ?

 

TownManager of jserver :

 

public static final L2TownZone getTown(int townId)
    {
        for (L2TownZone temp : ZoneManager.getInstance().getAllZones(L2TownZone.class))
        {
            if (temp.getTownId() == townId)
            {
                return temp;
            }
        }
        return null;
    }
    
    /**
     * Returns the town at that position (if any)
     * @param x
     * @param y
     * @param z
     * @return
     */
    public static final L2TownZone getTown(int x, int y, int z)
    {
        for (L2ZoneType temp : ZoneManager.getInstance().getZones(x, y, z))
        {
            if (temp instanceof L2TownZone)
            {
                return (L2TownZone) temp;
            }
        }
        return null;
    }

6 answers to this question

Recommended Posts

  • 0
Posted (edited)
6 minutes ago, melron said:

TownWarManager:106

 

106 

 

this TownManager.getTown(Config.TW_TOWN_ID).setIsTWZone(true);

 

for 

ZoneManager.getInstance().getZoneById(i, TownZone.class).setIsTWZone(true);

Edited by l2jkain
  • 0
Posted

what is 'i'? 

 

you could use a null check first...

final TownZone tempZone = ZoneManager.getInstance().getZoneById(i, TownZone.class);
if (tempZone != null)
	tempZone.setIsTWZone(true);
else
	System.out.println("Zone not found with id " + i);

 

  • 0
Posted
12 minutes ago, melron said:

what is 'i'? 

 

you could use a null check first...


final TownZone tempZone = ZoneManager.getInstance().getZoneById(i, TownZone.class);
if (tempZone != null)
	tempZone.setIsTWZone(true);
else
	System.out.println("Zone not found with id " + i);

 

 


 

I created a check in ZoneManager for all town zones and it worked perfectly,

this should work.

ZoneManager.getInstance (). GetZoneById (i, TownZone.class) .setIsTWZone (true)

I created this in ZoneManager


public TownZone getTown (int townId)
{
for (TownZone temp: ZoneManager.getInstance (). getAllZones (TownZone.class))
{
if (temp.getTownId () == townId)
return temp;
}
return null;
}

 

   

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...