L2MapRegion.java 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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;
  16. import java.util.ArrayList;
  17. import java.util.List;
  18. import java.util.Map;
  19. import javolution.util.FastMap;
  20. import com.l2jserver.Config;
  21. import com.l2jserver.gameserver.model.base.Race;
  22. import com.l2jserver.util.Rnd;
  23. /**
  24. * @author Nyaran
  25. */
  26. public class L2MapRegion
  27. {
  28. private String _name = null;
  29. private String _town = null;
  30. private int _locId = -1;
  31. private int _castle = -1;
  32. private int _bbs = -1;
  33. private List<int[]> _maps = null;
  34. private List<Location> _spawnLocs = null;
  35. private List<Location> _otherSpawnLocs = null;
  36. private List<Location> _chaoticSpawnLocs = null;
  37. private List<Location> _banishSpawnLocs = null;
  38. private Map<Race, String> _bannedRace = new FastMap<Race, String>();
  39. public L2MapRegion(String name, String town, int locId, int castle, int bbs)
  40. {
  41. _name = name;
  42. _town = town;
  43. _locId = locId;
  44. _castle = castle;
  45. _bbs = bbs;
  46. }
  47. public final String getName()
  48. {
  49. return _name;
  50. }
  51. public final String getTown()
  52. {
  53. return _town;
  54. }
  55. public final int getLocId()
  56. {
  57. return _locId;
  58. }
  59. public final int getCastle()
  60. {
  61. return _castle;
  62. }
  63. public final int getBbs()
  64. {
  65. return _bbs;
  66. }
  67. public final void addMap(int x, int y)
  68. {
  69. if (_maps == null)
  70. _maps = new ArrayList<int[]>();
  71. _maps.add(new int[] { x, y });
  72. }
  73. public final List<int[]> getMaps()
  74. {
  75. return _maps;
  76. }
  77. public final boolean isZoneInRegion(int x, int y)
  78. {
  79. if (_maps == null)
  80. return false;
  81. for (int[] map : _maps)
  82. {
  83. if (map[0] == x && map[1] == y)
  84. return true;
  85. }
  86. return false;
  87. }
  88. // Respawn
  89. public final void addSpawn(int x, int y, int z)
  90. {
  91. if (_spawnLocs == null)
  92. _spawnLocs = new ArrayList<Location>();
  93. _spawnLocs.add(new Location(x, y, z));
  94. }
  95. public final void addOtherSpawn(int x, int y, int z)
  96. {
  97. if (_otherSpawnLocs == null)
  98. _otherSpawnLocs = new ArrayList<Location>();
  99. _otherSpawnLocs.add(new Location(x, y, z));
  100. }
  101. public final void addChaoticSpawn(int x, int y, int z)
  102. {
  103. if (_chaoticSpawnLocs == null)
  104. _chaoticSpawnLocs = new ArrayList<Location>();
  105. _chaoticSpawnLocs.add(new Location(x, y, z));
  106. }
  107. public final void addBanishSpawn(int x, int y, int z)
  108. {
  109. if (_banishSpawnLocs == null)
  110. _banishSpawnLocs = new ArrayList<Location>();
  111. _banishSpawnLocs.add(new Location(x, y, z));
  112. }
  113. public final List<Location> getSpawns()
  114. {
  115. return _spawnLocs;
  116. }
  117. public final Location getSpawnLoc()
  118. {
  119. if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
  120. return _spawnLocs.get(Rnd.get(_spawnLocs.size()));
  121. else
  122. return _spawnLocs.get(0);
  123. }
  124. public final Location getOtherSpawnLoc()
  125. {
  126. if (_otherSpawnLocs != null)
  127. {
  128. if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
  129. return _otherSpawnLocs.get(Rnd.get(_otherSpawnLocs.size()));
  130. else
  131. return _otherSpawnLocs.get(0);
  132. }
  133. else
  134. return getSpawnLoc();
  135. }
  136. public final Location getChaoticSpawnLoc()
  137. {
  138. if (_chaoticSpawnLocs != null)
  139. {
  140. if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
  141. return _chaoticSpawnLocs.get(Rnd.get(_chaoticSpawnLocs.size()));
  142. else
  143. return _chaoticSpawnLocs.get(0);
  144. }
  145. else
  146. return getSpawnLoc();
  147. }
  148. public final Location getBanishSpawnLoc()
  149. {
  150. if (_banishSpawnLocs != null)
  151. {
  152. if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
  153. return _banishSpawnLocs.get(Rnd.get(_banishSpawnLocs.size()));
  154. else
  155. return _banishSpawnLocs.get(0);
  156. }
  157. else
  158. return getSpawnLoc();
  159. }
  160. public final void addBannedRace(String race, String point)
  161. {
  162. _bannedRace.put(Race.valueOf(race), point);
  163. }
  164. public final Map<Race, String> getBannedRace()
  165. {
  166. return _bannedRace;
  167. }
  168. }