L2ZoneRespawn.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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.model.zone;
  16. import java.util.ArrayList;
  17. import java.util.List;
  18. import com.l2jserver.Config;
  19. import com.l2jserver.gameserver.model.Location;
  20. import com.l2jserver.util.Rnd;
  21. /**
  22. * Abstract zone with spawn locations
  23. * @author DS, Nyaran (rework 10/07/2011)
  24. *
  25. */
  26. public abstract class L2ZoneRespawn extends L2ZoneType
  27. {
  28. private List<Location> _spawnLocs = null;
  29. private List<Location> _otherSpawnLocs = null;
  30. private List<Location> _chaoticSpawnLocs = null;
  31. private List<Location> _banishSpawnLocs = null;
  32. protected L2ZoneRespawn(int id)
  33. {
  34. super(id);
  35. }
  36. public final void addSpawn(int x, int y, int z)
  37. {
  38. if (_spawnLocs == null)
  39. _spawnLocs = new ArrayList<Location>();
  40. _spawnLocs.add(new Location(x, y, z));
  41. }
  42. public final void addOtherSpawn(int x, int y, int z)
  43. {
  44. if (_otherSpawnLocs == null)
  45. _otherSpawnLocs = new ArrayList<Location>();
  46. _otherSpawnLocs.add(new Location(x, y, z));
  47. }
  48. public final void addChaoticSpawn(int x, int y, int z)
  49. {
  50. if (_chaoticSpawnLocs == null)
  51. _chaoticSpawnLocs = new ArrayList<Location>();
  52. _chaoticSpawnLocs.add(new Location(x, y, z));
  53. }
  54. public final void addBanishSpawn(int x, int y, int z)
  55. {
  56. if (_banishSpawnLocs == null)
  57. _banishSpawnLocs = new ArrayList<Location>();
  58. _banishSpawnLocs.add(new Location(x, y, z));
  59. }
  60. public final List<Location> getSpawns()
  61. {
  62. return _spawnLocs;
  63. }
  64. public final Location getSpawnLoc()
  65. {
  66. if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
  67. return _spawnLocs.get(Rnd.get(_spawnLocs.size()));
  68. else
  69. return _spawnLocs.get(0);
  70. }
  71. public final Location getOtherSpawnLoc()
  72. {
  73. if (_otherSpawnLocs != null)
  74. {
  75. if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
  76. return _otherSpawnLocs.get(Rnd.get(_otherSpawnLocs.size()));
  77. else
  78. return _otherSpawnLocs.get(0);
  79. }
  80. else
  81. return getSpawnLoc();
  82. }
  83. public final Location getChaoticSpawnLoc()
  84. {
  85. if (_chaoticSpawnLocs != null)
  86. {
  87. if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
  88. return _chaoticSpawnLocs.get(Rnd.get(_chaoticSpawnLocs.size()));
  89. else
  90. return _chaoticSpawnLocs.get(0);
  91. }
  92. else
  93. return getSpawnLoc();
  94. }
  95. public final Location getBanishSpawnLoc()
  96. {
  97. if (_banishSpawnLocs != null)
  98. {
  99. if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
  100. return _banishSpawnLocs.get(Rnd.get(_banishSpawnLocs.size()));
  101. else
  102. return _banishSpawnLocs.get(0);
  103. }
  104. else
  105. return getSpawnLoc();
  106. }
  107. }