2
0

L2MapRegion.java 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /*
  2. * Copyright (C) 2004-2013 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.model;
  20. import java.util.ArrayList;
  21. import java.util.HashMap;
  22. import java.util.List;
  23. import java.util.Map;
  24. import com.l2jserver.Config;
  25. import com.l2jserver.gameserver.enums.PcRace;
  26. import com.l2jserver.util.Rnd;
  27. /**
  28. * @author Nyaran
  29. */
  30. public class L2MapRegion
  31. {
  32. private final String _name;
  33. private final String _town;
  34. private final int _locId;
  35. private final int _castle;
  36. private final int _bbs;
  37. private List<int[]> _maps = null;
  38. private List<Location> _spawnLocs = null;
  39. private List<Location> _otherSpawnLocs = null;
  40. private List<Location> _chaoticSpawnLocs = null;
  41. private List<Location> _banishSpawnLocs = null;
  42. private final Map<PcRace, String> _bannedRace = new HashMap<>();
  43. public L2MapRegion(String name, String town, int locId, int castle, int bbs)
  44. {
  45. _name = name;
  46. _town = town;
  47. _locId = locId;
  48. _castle = castle;
  49. _bbs = bbs;
  50. }
  51. public final String getName()
  52. {
  53. return _name;
  54. }
  55. public final String getTown()
  56. {
  57. return _town;
  58. }
  59. public final int getLocId()
  60. {
  61. return _locId;
  62. }
  63. public final int getCastle()
  64. {
  65. return _castle;
  66. }
  67. public final int getBbs()
  68. {
  69. return _bbs;
  70. }
  71. public final void addMap(int x, int y)
  72. {
  73. if (_maps == null)
  74. {
  75. _maps = new ArrayList<>();
  76. }
  77. _maps.add(new int[]
  78. {
  79. x,
  80. y
  81. });
  82. }
  83. public final List<int[]> getMaps()
  84. {
  85. return _maps;
  86. }
  87. public final boolean isZoneInRegion(int x, int y)
  88. {
  89. if (_maps == null)
  90. {
  91. return false;
  92. }
  93. for (int[] map : _maps)
  94. {
  95. if ((map[0] == x) && (map[1] == y))
  96. {
  97. return true;
  98. }
  99. }
  100. return false;
  101. }
  102. // Respawn
  103. public final void addSpawn(int x, int y, int z)
  104. {
  105. if (_spawnLocs == null)
  106. {
  107. _spawnLocs = new ArrayList<>();
  108. }
  109. _spawnLocs.add(new Location(x, y, z));
  110. }
  111. public final void addOtherSpawn(int x, int y, int z)
  112. {
  113. if (_otherSpawnLocs == null)
  114. {
  115. _otherSpawnLocs = new ArrayList<>();
  116. }
  117. _otherSpawnLocs.add(new Location(x, y, z));
  118. }
  119. public final void addChaoticSpawn(int x, int y, int z)
  120. {
  121. if (_chaoticSpawnLocs == null)
  122. {
  123. _chaoticSpawnLocs = new ArrayList<>();
  124. }
  125. _chaoticSpawnLocs.add(new Location(x, y, z));
  126. }
  127. public final void addBanishSpawn(int x, int y, int z)
  128. {
  129. if (_banishSpawnLocs == null)
  130. {
  131. _banishSpawnLocs = new ArrayList<>();
  132. }
  133. _banishSpawnLocs.add(new Location(x, y, z));
  134. }
  135. public final List<Location> getSpawns()
  136. {
  137. return _spawnLocs;
  138. }
  139. public final Location getSpawnLoc()
  140. {
  141. if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
  142. {
  143. return _spawnLocs.get(Rnd.get(_spawnLocs.size()));
  144. }
  145. return _spawnLocs.get(0);
  146. }
  147. public final Location getOtherSpawnLoc()
  148. {
  149. if (_otherSpawnLocs != null)
  150. {
  151. if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
  152. {
  153. return _otherSpawnLocs.get(Rnd.get(_otherSpawnLocs.size()));
  154. }
  155. return _otherSpawnLocs.get(0);
  156. }
  157. return getSpawnLoc();
  158. }
  159. public final Location getChaoticSpawnLoc()
  160. {
  161. if (_chaoticSpawnLocs != null)
  162. {
  163. if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
  164. {
  165. return _chaoticSpawnLocs.get(Rnd.get(_chaoticSpawnLocs.size()));
  166. }
  167. return _chaoticSpawnLocs.get(0);
  168. }
  169. return getSpawnLoc();
  170. }
  171. public final Location getBanishSpawnLoc()
  172. {
  173. if (_banishSpawnLocs != null)
  174. {
  175. if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
  176. {
  177. return _banishSpawnLocs.get(Rnd.get(_banishSpawnLocs.size()));
  178. }
  179. return _banishSpawnLocs.get(0);
  180. }
  181. return getSpawnLoc();
  182. }
  183. public final void addBannedRace(String race, String point)
  184. {
  185. _bannedRace.put(PcRace.valueOf(race), point);
  186. }
  187. public final Map<PcRace, String> getBannedRace()
  188. {
  189. return _bannedRace;
  190. }
  191. }