ZoneManager.java 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.instancemanager;
  16. import gnu.trove.TObjectProcedure;
  17. import java.io.File;
  18. import java.lang.reflect.Constructor;
  19. import java.util.Collection;
  20. import java.util.Iterator;
  21. import java.util.List;
  22. import java.util.Map;
  23. import java.util.logging.Level;
  24. import java.util.logging.Logger;
  25. import javax.xml.parsers.DocumentBuilderFactory;
  26. import javolution.util.FastList;
  27. import javolution.util.FastMap;
  28. import org.w3c.dom.Document;
  29. import org.w3c.dom.NamedNodeMap;
  30. import org.w3c.dom.Node;
  31. import com.l2jserver.Config;
  32. import com.l2jserver.gameserver.model.L2ItemInstance;
  33. import com.l2jserver.gameserver.model.L2Object;
  34. import com.l2jserver.gameserver.model.L2World;
  35. import com.l2jserver.gameserver.model.L2WorldRegion;
  36. import com.l2jserver.gameserver.model.actor.L2Character;
  37. import com.l2jserver.gameserver.model.zone.L2ZoneRespawn;
  38. import com.l2jserver.gameserver.model.zone.L2ZoneType;
  39. import com.l2jserver.gameserver.model.zone.form.ZoneCuboid;
  40. import com.l2jserver.gameserver.model.zone.form.ZoneCylinder;
  41. import com.l2jserver.gameserver.model.zone.form.ZoneNPoly;
  42. import com.l2jserver.gameserver.model.zone.type.L2ArenaZone;
  43. import com.l2jserver.gameserver.model.zone.type.L2OlympiadStadiumZone;
  44. import com.l2jserver.gameserver.model.zone.type.L2RespawnZone;
  45. /**
  46. * This class manages the zones
  47. *
  48. * @author durgus
  49. */
  50. public class ZoneManager
  51. {
  52. private static final Logger _log = Logger.getLogger(ZoneManager.class.getName());
  53. //private final FastMap<Integer, L2ZoneType> _zones = new FastMap<Integer, L2ZoneType>();
  54. private final Map<Class<? extends L2ZoneType>, Map<Integer, ? extends L2ZoneType>> _classZones = new FastMap<Class<? extends L2ZoneType>, Map<Integer, ? extends L2ZoneType>>();
  55. private int _lastDynamicId = 300000;
  56. private List<L2ItemInstance> _debugItems;
  57. public static final ZoneManager getInstance()
  58. {
  59. return SingletonHolder._instance;
  60. }
  61. // =========================================================
  62. // Data Field
  63. // =========================================================
  64. // Constructor
  65. private ZoneManager()
  66. {
  67. load();
  68. }
  69. @SuppressWarnings("deprecation")
  70. public void reload()
  71. {
  72. // int zoneCount = 0;
  73. // Get the world regions
  74. int count = 0;
  75. L2WorldRegion[][] worldRegions = L2World.getInstance().getAllWorldRegions();
  76. for (int x = 0; x < worldRegions.length; x++)
  77. {
  78. for (int y = 0; y < worldRegions[x].length; y++)
  79. {
  80. worldRegions[x][y].getZones().clear();
  81. count++;
  82. }
  83. }
  84. GrandBossManager.getInstance().getZones().clear();
  85. _log.info("Removed zones in " + count + " regions.");
  86. // Load the zones
  87. load();
  88. L2World.getInstance().forEachObject(new ForEachCharacterRevalidateZone());
  89. }
  90. private final class ForEachCharacterRevalidateZone implements TObjectProcedure<L2Object>
  91. {
  92. @Override
  93. public final boolean execute(final L2Object o)
  94. {
  95. if (o instanceof L2Character)
  96. ((L2Character) o).revalidateZone(true);
  97. return true;
  98. }
  99. }
  100. // =========================================================
  101. // Method - Private
  102. private final void load()
  103. {
  104. _log.info("Loading zones...");
  105. _classZones.clear();
  106. // Get the world regions
  107. L2WorldRegion[][] worldRegions = L2World.getInstance().getAllWorldRegions();
  108. // Load the zone xml
  109. try
  110. {
  111. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  112. factory.setValidating(false);
  113. factory.setIgnoringComments(true);
  114. final File dir = new File(Config.DATAPACK_ROOT, "data/zones");
  115. if (!dir.exists())
  116. {
  117. _log.config("Dir " + dir.getAbsolutePath() + " not exists");
  118. return;
  119. }
  120. File[] files = dir.listFiles();
  121. FastList<File> hash = new FastList<File>(files.length);
  122. for (File f : files)
  123. {
  124. // default file first
  125. if ("zone.xml".equalsIgnoreCase(f.getName()))
  126. hash.addFirst(f);
  127. else if (f.getName().endsWith(".xml"))
  128. hash.add(f);
  129. }
  130. Document doc;
  131. NamedNodeMap attrs;
  132. Node attribute;
  133. String zoneName;
  134. int[][] coords;
  135. int zoneId, minZ, maxZ;
  136. String zoneType, zoneShape;
  137. for (File f : hash)
  138. {
  139. doc = factory.newDocumentBuilder().parse(f);
  140. for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
  141. {
  142. if ("list".equalsIgnoreCase(n.getNodeName()))
  143. {
  144. attrs = n.getAttributes();
  145. attribute = attrs.getNamedItem("enabled");
  146. if (attribute != null && !Boolean.parseBoolean(attribute.getNodeValue()))
  147. continue;
  148. for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
  149. {
  150. if ("zone".equalsIgnoreCase(d.getNodeName()))
  151. {
  152. attrs = d.getAttributes();
  153. attribute = attrs.getNamedItem("id");
  154. if (attribute != null)
  155. zoneId = Integer.parseInt(attribute.getNodeValue());
  156. else
  157. zoneId = _lastDynamicId++;
  158. attribute = attrs.getNamedItem("name");
  159. if (attribute != null)
  160. zoneName = attribute.getNodeValue();
  161. else
  162. zoneName = null;
  163. attribute = attrs.getNamedItem("minZ");
  164. if (attribute != null)
  165. minZ = Integer.parseInt(attribute.getNodeValue());
  166. else
  167. {
  168. _log.warning("ZoneData: Missing minZ for zone: " + zoneId + " in file: " + f.getName());
  169. continue;
  170. }
  171. attribute = attrs.getNamedItem("maxZ");
  172. if (attribute != null)
  173. maxZ = Integer.parseInt(attribute.getNodeValue());
  174. else
  175. {
  176. _log.warning("ZoneData: Missing maxZ for zone: " + zoneId + " in file: " + f.getName());
  177. continue;
  178. }
  179. attribute = attrs.getNamedItem("type");
  180. if (attribute != null)
  181. zoneType = attribute.getNodeValue();
  182. else
  183. {
  184. _log.warning("ZoneData: Missing type for zone: " + zoneId + " in file: " + f.getName());
  185. continue;
  186. }
  187. attribute = attrs.getNamedItem("shape");
  188. if (attribute != null)
  189. zoneShape = attribute.getNodeValue();
  190. else
  191. {
  192. _log.warning("ZoneData: Missing shape for zone: " + zoneId + " in file: " + f.getName());
  193. continue;
  194. }
  195. // Create the zone
  196. Class<?> newZone;
  197. try
  198. {
  199. newZone = Class.forName("com.l2jserver.gameserver.model.zone.type.L2" + zoneType);
  200. }
  201. catch (ClassNotFoundException e)
  202. {
  203. _log.warning("ZoneData: No such zone type: " + zoneType + " in file: " + f.getName());
  204. continue;
  205. }
  206. Constructor<?> zoneConstructor = newZone.getConstructor(int.class);
  207. L2ZoneType temp = (L2ZoneType) zoneConstructor.newInstance(zoneId);
  208. // Get the zone shape from sql
  209. try
  210. {
  211. coords = null;
  212. int[] point;
  213. FastList<int[]> rs = FastList.newInstance();
  214. try
  215. {
  216. // loading from XML first
  217. for (Node cd = d.getFirstChild(); cd != null; cd = cd.getNextSibling())
  218. {
  219. if ("node".equalsIgnoreCase(cd.getNodeName()))
  220. {
  221. attrs = cd.getAttributes();
  222. point = new int[2];
  223. point[0] = Integer.parseInt(attrs.getNamedItem("X").getNodeValue());
  224. point[1] = Integer.parseInt(attrs.getNamedItem("Y").getNodeValue());
  225. rs.add(point);
  226. }
  227. }
  228. coords = rs.toArray(new int[rs.size()][]);
  229. }
  230. finally
  231. {
  232. FastList.recycle(rs);
  233. }
  234. if (coords == null || coords.length == 0)
  235. {
  236. _log.warning("ZoneData: missing data for zone: " + zoneId +" in both XML and SQL, file: " + f.getName());
  237. continue;
  238. }
  239. // Create this zone. Parsing for cuboids is a
  240. // bit different than for other polygons
  241. // cuboids need exactly 2 points to be defined.
  242. // Other polygons need at least 3 (one per
  243. // vertex)
  244. if (zoneShape.equalsIgnoreCase("Cuboid"))
  245. {
  246. if (coords.length == 2)
  247. temp.setZone(new ZoneCuboid(coords[0][0], coords[1][0], coords[0][1], coords[1][1], minZ, maxZ));
  248. else
  249. {
  250. _log.warning("ZoneData: Missing cuboid vertex in sql data for zone: " + zoneId + " in file: " + f.getName());
  251. continue;
  252. }
  253. }
  254. else if (zoneShape.equalsIgnoreCase("NPoly"))
  255. {
  256. // nPoly needs to have at least 3 vertices
  257. if (coords.length > 2)
  258. {
  259. final int[] aX = new int[coords.length];
  260. final int[] aY = new int[coords.length];
  261. for (int i = 0; i < coords.length; i++)
  262. {
  263. aX[i] = coords[i][0];
  264. aY[i] = coords[i][1];
  265. }
  266. temp.setZone(new ZoneNPoly(aX, aY, minZ, maxZ));
  267. }
  268. else
  269. {
  270. _log.warning("ZoneData: Bad data for zone: " + zoneId + " in file: " + f.getName());
  271. continue;
  272. }
  273. }
  274. else if (zoneShape.equalsIgnoreCase("Cylinder"))
  275. {
  276. // A Cylinder zone requires a center point
  277. // at x,y and a radius
  278. attrs = d.getAttributes();
  279. final int zoneRad = Integer.parseInt(attrs.getNamedItem("rad").getNodeValue());
  280. if (coords.length == 1 && zoneRad > 0)
  281. temp.setZone(new ZoneCylinder(coords[0][0], coords[0][1], minZ, maxZ, zoneRad));
  282. else
  283. {
  284. _log.warning("ZoneData: Bad data for zone: " + zoneId + " in file: " + f.getName());
  285. continue;
  286. }
  287. }
  288. else
  289. {
  290. _log.warning("ZoneData: Unknown shape: " + zoneShape + " in file: " + f.getName());
  291. continue;
  292. }
  293. }
  294. catch (Exception e)
  295. {
  296. _log.log(Level.WARNING, "ZoneData: Failed to load zone " + zoneId + " coordinates: " + e.getMessage(), e);
  297. }
  298. // Check for additional parameters
  299. for (Node cd = d.getFirstChild(); cd != null; cd = cd.getNextSibling())
  300. {
  301. if ("stat".equalsIgnoreCase(cd.getNodeName()))
  302. {
  303. attrs = cd.getAttributes();
  304. String name = attrs.getNamedItem("name").getNodeValue();
  305. String val = attrs.getNamedItem("val").getNodeValue();
  306. temp.setParameter(name, val);
  307. }
  308. else if ("spawn".equalsIgnoreCase(cd.getNodeName()) && temp instanceof L2ZoneRespawn)
  309. {
  310. attrs = cd.getAttributes();
  311. int spawnX = Integer.parseInt(attrs.getNamedItem("X").getNodeValue());
  312. int spawnY = Integer.parseInt(attrs.getNamedItem("Y").getNodeValue());
  313. int spawnZ = Integer.parseInt(attrs.getNamedItem("Z").getNodeValue());
  314. Node val = attrs.getNamedItem("isOther");
  315. boolean other = val != null && Boolean.parseBoolean(val.getNodeValue());
  316. val = attrs.getNamedItem("isChaotic");
  317. boolean chaotic = val != null && Boolean.parseBoolean(val.getNodeValue());
  318. val = attrs.getNamedItem("isBanish");
  319. boolean banish = val != null && Boolean.parseBoolean(val.getNodeValue());
  320. if (other)
  321. ((L2ZoneRespawn) temp).addOtherSpawn(spawnX, spawnY, spawnZ);
  322. else if (chaotic)
  323. ((L2ZoneRespawn) temp).addChaoticSpawn(spawnX, spawnY, spawnZ);
  324. else if (banish)
  325. ((L2ZoneRespawn) temp).addBanishSpawn(spawnX, spawnY, spawnZ);
  326. else
  327. ((L2ZoneRespawn) temp).addSpawn(spawnX, spawnY, spawnZ);
  328. }
  329. else if ("race".equalsIgnoreCase(cd.getNodeName()) && temp instanceof L2RespawnZone)
  330. {
  331. attrs = cd.getAttributes();
  332. String race = attrs.getNamedItem("name").getNodeValue();
  333. String point = attrs.getNamedItem("point").getNodeValue();
  334. ((L2RespawnZone) temp).addRaceRespawnPoint(race, point);
  335. }
  336. }
  337. if (checkId(zoneId))
  338. _log.config("Caution: Zone (" + zoneId + ") from file: " + f.getName() + " overrides previos definition.");
  339. if (zoneName != null && !zoneName.isEmpty())
  340. temp.setName(zoneName);
  341. addZone(zoneId, temp);
  342. // Register the zone into any world region it
  343. // intersects with...
  344. // currently 11136 test for each zone :>
  345. int ax, ay, bx, by;
  346. for (int x = 0; x < worldRegions.length; x++)
  347. {
  348. for (int y = 0; y < worldRegions[x].length; y++)
  349. {
  350. ax = (x - L2World.OFFSET_X) << L2World.SHIFT_BY;
  351. bx = ((x + 1) - L2World.OFFSET_X) << L2World.SHIFT_BY;
  352. ay = (y - L2World.OFFSET_Y) << L2World.SHIFT_BY;
  353. by = ((y + 1) - L2World.OFFSET_Y) << L2World.SHIFT_BY;
  354. if (temp.getZone().intersectsRectangle(ax, bx, ay, by))
  355. {
  356. if (Config.DEBUG)
  357. {
  358. _log.info("Zone (" + zoneId + ") added to: " + x + " " + y);
  359. }
  360. worldRegions[x][y].addZone(temp);
  361. }
  362. }
  363. }
  364. }
  365. }
  366. }
  367. }
  368. }
  369. }
  370. catch (Exception e)
  371. {
  372. _log.log(Level.SEVERE, "Error while loading zones.", e);
  373. return;
  374. }
  375. _log.info("Done: loaded " + _classZones.size() + " zone classes and "+getSize()+" zones.");
  376. }
  377. public int getSize()
  378. {
  379. int i = 0;
  380. for (Map<Integer, ? extends L2ZoneType> map : _classZones.values())
  381. {
  382. i += map.size();
  383. }
  384. return i;
  385. }
  386. public boolean checkId(int id)
  387. {
  388. for (Map<Integer, ? extends L2ZoneType> map : _classZones.values())
  389. {
  390. if (map.containsKey(id))
  391. return true;
  392. }
  393. return false;
  394. }
  395. /**
  396. * Add new zone
  397. *
  398. * @param zone
  399. */
  400. @SuppressWarnings("unchecked")
  401. public <T extends L2ZoneType> void addZone(Integer id, T zone)
  402. {
  403. //_zones.put(id, zone);
  404. Map<Integer, T> map = (Map<Integer, T>) _classZones.get(zone.getClass());
  405. if (map == null)
  406. {
  407. map = new FastMap<Integer, T>();
  408. map.put(id, zone);
  409. _classZones.put(zone.getClass(), map);
  410. }
  411. else
  412. map.put(id, zone);
  413. }
  414. /**
  415. * Returns all zones registered with the ZoneManager.
  416. * To minimise iteration processing retrieve zones from L2WorldRegion for a specific location instead.
  417. * @return zones
  418. * @see #getAllZones(Class)
  419. */
  420. @Deprecated
  421. public Collection<L2ZoneType> getAllZones()
  422. {
  423. FastList<L2ZoneType> zones = new FastList<L2ZoneType>();
  424. for (Map<Integer, ? extends L2ZoneType> map : _classZones.values())
  425. {
  426. zones.addAll(map.values());
  427. }
  428. return zones;
  429. }
  430. /**
  431. * Return all zones by class type
  432. * @param <T>
  433. * @param zoneType Zone class
  434. * @return Collection of zones
  435. */
  436. @SuppressWarnings("unchecked")
  437. public <T extends L2ZoneType> Collection<T> getAllZones(Class<T> zoneType)
  438. {
  439. return (Collection<T>) _classZones.get(zoneType).values();
  440. }
  441. /**
  442. * Get zone by ID
  443. * @param id
  444. * @return
  445. * @see #getZoneById(int, Class)
  446. */
  447. public L2ZoneType getZoneById(int id)
  448. {
  449. for (Map<Integer, ? extends L2ZoneType> map : _classZones.values())
  450. {
  451. if (map.containsKey(id))
  452. return map.get(id);
  453. }
  454. return null;
  455. }
  456. /**
  457. * Get zone by ID and zone class
  458. * @param id
  459. * @param zoneType
  460. * @return zone
  461. */
  462. @SuppressWarnings("unchecked")
  463. public <T extends L2ZoneType> T getZoneById(int id, Class<T> zoneType)
  464. {
  465. return (T) _classZones.get(zoneType).get(id);
  466. }
  467. /**
  468. * Returns all zones from where the object is located
  469. *
  470. * @param object
  471. * @return zones
  472. */
  473. public FastList<L2ZoneType> getZones(L2Object object)
  474. {
  475. return getZones(object.getX(), object.getY(), object.getZ());
  476. }
  477. /**
  478. * Returns zone from where the object is located by type
  479. *
  480. * @param object
  481. * @param type
  482. * @return zone
  483. */
  484. public <T extends L2ZoneType> T getZone(L2Object object, Class<T> type)
  485. {
  486. if (object == null)
  487. return null;
  488. return getZone(object.getX(), object.getY(), object.getZ(), type);
  489. }
  490. /**
  491. * Returns all zones from given coordinates (plane)
  492. *
  493. * @param x
  494. * @param y
  495. * @return zones
  496. */
  497. public FastList<L2ZoneType> getZones(int x, int y)
  498. {
  499. L2WorldRegion region = L2World.getInstance().getRegion(x, y);
  500. FastList<L2ZoneType> temp = new FastList<L2ZoneType>();
  501. for (L2ZoneType zone : region.getZones())
  502. {
  503. if (zone.isInsideZone(x, y))
  504. temp.add(zone);
  505. }
  506. return temp;
  507. }
  508. /**
  509. * Returns all zones from given coordinates
  510. *
  511. * @param x
  512. * @param y
  513. * @param z
  514. * @return zones
  515. */
  516. public FastList<L2ZoneType> getZones(int x, int y, int z)
  517. {
  518. L2WorldRegion region = L2World.getInstance().getRegion(x, y);
  519. FastList<L2ZoneType> temp = new FastList<L2ZoneType>();
  520. for (L2ZoneType zone : region.getZones())
  521. {
  522. if (zone.isInsideZone(x, y, z))
  523. temp.add(zone);
  524. }
  525. return temp;
  526. }
  527. /**
  528. * Returns zone from given coordinates
  529. *
  530. * @param x
  531. * @param y
  532. * @param z
  533. * @param type
  534. * @return zone
  535. */
  536. @SuppressWarnings("unchecked")
  537. public <T extends L2ZoneType> T getZone(int x, int y, int z, Class<T> type)
  538. {
  539. L2WorldRegion region = L2World.getInstance().getRegion(x, y);
  540. for (L2ZoneType zone : region.getZones())
  541. {
  542. if (zone.isInsideZone(x, y, z) && type.isInstance(zone))
  543. return (T) zone;
  544. }
  545. return null;
  546. }
  547. public final L2ArenaZone getArena(L2Character character)
  548. {
  549. if (character == null)
  550. return null;
  551. for (L2ZoneType temp : ZoneManager.getInstance().getZones(character.getX(), character.getY(), character.getZ()))
  552. {
  553. if (temp instanceof L2ArenaZone && temp.isCharacterInZone(character))
  554. return ((L2ArenaZone) temp);
  555. }
  556. return null;
  557. }
  558. public final L2OlympiadStadiumZone getOlympiadStadium(L2Character character)
  559. {
  560. if (character == null)
  561. return null;
  562. for (L2ZoneType temp : ZoneManager.getInstance().getZones(character.getX(), character.getY(), character.getZ()))
  563. {
  564. if (temp instanceof L2OlympiadStadiumZone && temp.isCharacterInZone(character))
  565. return ((L2OlympiadStadiumZone) temp);
  566. }
  567. return null;
  568. }
  569. /**
  570. * For testing purposes only
  571. * @param <T>
  572. * @param obj
  573. * @param type
  574. * @return
  575. */
  576. @SuppressWarnings("unchecked")
  577. public <T extends L2ZoneType> T getClosestZone(L2Object obj, Class<T> type)
  578. {
  579. T zone = getZone(obj, type);
  580. if (zone == null)
  581. {
  582. double closestdis = Double.MAX_VALUE;
  583. for (T temp : (Collection<T>) _classZones.get(type).values())
  584. {
  585. double distance = temp.getDistanceToZone(obj);
  586. if (distance < closestdis)
  587. {
  588. closestdis = distance;
  589. zone = temp;
  590. }
  591. }
  592. return zone;
  593. }
  594. else
  595. return zone;
  596. }
  597. /**
  598. * General storage for debug items used for visualizing zones.
  599. * @return list of items
  600. */
  601. public List<L2ItemInstance> getDebugItems()
  602. {
  603. if (_debugItems == null)
  604. _debugItems = new FastList<L2ItemInstance>();
  605. return _debugItems;
  606. }
  607. /**
  608. * Remove all debug items from l2world
  609. */
  610. public void clearDebugItems()
  611. {
  612. if (_debugItems != null)
  613. {
  614. Iterator<L2ItemInstance> it = _debugItems.iterator();
  615. while (it.hasNext())
  616. {
  617. L2ItemInstance item = it.next();
  618. if (item != null)
  619. item.decayMe();
  620. it.remove();
  621. }
  622. }
  623. }
  624. @SuppressWarnings("synthetic-access")
  625. private static class SingletonHolder
  626. {
  627. protected static final ZoneManager _instance = new ZoneManager();
  628. }
  629. }