L2ZoneManager.java 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 net.sf.l2j.gameserver.model.zone;
  16. import javolution.util.FastList;
  17. import net.sf.l2j.gameserver.model.L2Character;
  18. /**
  19. * This class manages all zones for a given world region
  20. *
  21. * @author durgus
  22. */
  23. public class L2ZoneManager
  24. {
  25. private final FastList<L2ZoneType> _zones;
  26. /**
  27. * The Constructor creates an initial zone list
  28. * use registerNewZone() / unregisterZone() to
  29. * change the zone list
  30. *
  31. */
  32. public L2ZoneManager()
  33. {
  34. _zones = new FastList<L2ZoneType>();
  35. }
  36. /**
  37. * Register a new zone object into the manager
  38. * @param zone
  39. */
  40. public void registerNewZone(L2ZoneType zone)
  41. {
  42. _zones.add(zone);
  43. }
  44. public FastList<L2ZoneType> getZones()
  45. {
  46. return _zones;
  47. }
  48. /**
  49. * Unregister a given zone from the manager (e.g. dynamic zones)
  50. * @param zone
  51. */
  52. public void unregisterZone(L2ZoneType zone)
  53. {
  54. _zones.remove(zone);
  55. }
  56. public void revalidateZones(L2Character character)
  57. {
  58. for (L2ZoneType e : _zones)
  59. {
  60. if (e != null)
  61. e.revalidateInZone(character);
  62. }
  63. }
  64. public void removeCharacter(L2Character character)
  65. {
  66. for (L2ZoneType e : _zones)
  67. {
  68. if (e != null)
  69. e.removeCharacter(character);
  70. }
  71. }
  72. public void onDeath(L2Character character)
  73. {
  74. for (L2ZoneType e : _zones)
  75. {
  76. if (e != null)
  77. e.onDieInside(character);
  78. }
  79. }
  80. public void onRevive(L2Character character)
  81. {
  82. for (L2ZoneType e : _zones)
  83. {
  84. if (e != null)
  85. e.onReviveInside(character);
  86. }
  87. }
  88. }