L2ZoneManager.java 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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) e.revalidateInZone(character);
  61. }
  62. }
  63. public void removeCharacter(L2Character character)
  64. {
  65. for (L2ZoneType e : _zones)
  66. {
  67. if(e != null) e.removeCharacter(character);
  68. }
  69. }
  70. public void onDeath(L2Character character)
  71. {
  72. for (L2ZoneType e : _zones)
  73. {
  74. if(e != null) e.onDieInside(character);
  75. }
  76. }
  77. public void onRevive(L2Character character)
  78. {
  79. for (L2ZoneType e : _zones)
  80. {
  81. if(e != null) e.onReviveInside(character);
  82. }
  83. }
  84. }