L2MapRegion.java 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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.HashMap;
  18. import java.util.List;
  19. import java.util.Map;
  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 final String _name;
  29. private final String _town;
  30. private final int _locId;
  31. private final int _castle;
  32. private final int _bbs;
  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 final Map<Race, String> _bannedRace = new HashMap<>();
  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. {
  71. _maps = new ArrayList<>();
  72. }
  73. _maps.add(new int[]
  74. {
  75. x,
  76. y
  77. });
  78. }
  79. public final List<int[]> getMaps()
  80. {
  81. return _maps;
  82. }
  83. public final boolean isZoneInRegion(int x, int y)
  84. {
  85. if (_maps == null)
  86. {
  87. return false;
  88. }
  89. for (int[] map : _maps)
  90. {
  91. if ((map[0] == x) && (map[1] == y))
  92. {
  93. return true;
  94. }
  95. }
  96. return false;
  97. }
  98. // Respawn
  99. public final void addSpawn(int x, int y, int z)
  100. {
  101. if (_spawnLocs == null)
  102. {
  103. _spawnLocs = new ArrayList<>();
  104. }
  105. _spawnLocs.add(new Location(x, y, z));
  106. }
  107. public final void addOtherSpawn(int x, int y, int z)
  108. {
  109. if (_otherSpawnLocs == null)
  110. {
  111. _otherSpawnLocs = new ArrayList<>();
  112. }
  113. _otherSpawnLocs.add(new Location(x, y, z));
  114. }
  115. public final void addChaoticSpawn(int x, int y, int z)
  116. {
  117. if (_chaoticSpawnLocs == null)
  118. {
  119. _chaoticSpawnLocs = new ArrayList<>();
  120. }
  121. _chaoticSpawnLocs.add(new Location(x, y, z));
  122. }
  123. public final void addBanishSpawn(int x, int y, int z)
  124. {
  125. if (_banishSpawnLocs == null)
  126. {
  127. _banishSpawnLocs = new ArrayList<>();
  128. }
  129. _banishSpawnLocs.add(new Location(x, y, z));
  130. }
  131. public final List<Location> getSpawns()
  132. {
  133. return _spawnLocs;
  134. }
  135. public final Location getSpawnLoc()
  136. {
  137. if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
  138. {
  139. return _spawnLocs.get(Rnd.get(_spawnLocs.size()));
  140. }
  141. return _spawnLocs.get(0);
  142. }
  143. public final Location getOtherSpawnLoc()
  144. {
  145. if (_otherSpawnLocs != null)
  146. {
  147. if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
  148. {
  149. return _otherSpawnLocs.get(Rnd.get(_otherSpawnLocs.size()));
  150. }
  151. return _otherSpawnLocs.get(0);
  152. }
  153. return getSpawnLoc();
  154. }
  155. public final Location getChaoticSpawnLoc()
  156. {
  157. if (_chaoticSpawnLocs != null)
  158. {
  159. if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
  160. {
  161. return _chaoticSpawnLocs.get(Rnd.get(_chaoticSpawnLocs.size()));
  162. }
  163. return _chaoticSpawnLocs.get(0);
  164. }
  165. return getSpawnLoc();
  166. }
  167. public final Location getBanishSpawnLoc()
  168. {
  169. if (_banishSpawnLocs != null)
  170. {
  171. if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
  172. {
  173. return _banishSpawnLocs.get(Rnd.get(_banishSpawnLocs.size()));
  174. }
  175. return _banishSpawnLocs.get(0);
  176. }
  177. return getSpawnLoc();
  178. }
  179. public final void addBannedRace(String race, String point)
  180. {
  181. _bannedRace.put(Race.valueOf(race), point);
  182. }
  183. public final Map<Race, String> getBannedRace()
  184. {
  185. return _bannedRace;
  186. }
  187. }