FishingZoneManager.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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.instancemanager;
  16. import java.util.logging.Logger;
  17. import javolution.util.FastList;
  18. import net.sf.l2j.gameserver.model.zone.type.L2FishingZone;
  19. import net.sf.l2j.gameserver.model.zone.type.L2WaterZone;
  20. public class FishingZoneManager
  21. {
  22. protected static final Logger _log = Logger.getLogger(FishingZoneManager.class.getName());
  23. // =========================================================
  24. private static FishingZoneManager _instance;
  25. public static final FishingZoneManager getInstance()
  26. {
  27. if (_instance == null)
  28. {
  29. _log.info("Initializing FishingZoneManager");
  30. _instance = new FishingZoneManager();
  31. }
  32. return _instance;
  33. }
  34. // =========================================================
  35. // =========================================================
  36. // Data Field
  37. private FastList<L2FishingZone> _fishingZones;
  38. private FastList<L2WaterZone> _waterZones;
  39. // =========================================================
  40. // Constructor
  41. public FishingZoneManager()
  42. {
  43. }
  44. // =========================================================
  45. // Property - Public
  46. public void addFishingZone(L2FishingZone fishingZone)
  47. {
  48. if (_fishingZones == null)
  49. _fishingZones = new FastList<L2FishingZone>();
  50. _fishingZones.add(fishingZone);
  51. }
  52. public void addWaterZone(L2WaterZone waterZone)
  53. {
  54. if (_waterZones == null)
  55. _waterZones = new FastList<L2WaterZone>();
  56. _waterZones.add(waterZone);
  57. }
  58. /* isInsideFishingZone() - This function was modified to check the coordinates without caring for Z.
  59. * This allows for the player to fish off bridges, into the water, or from other similar high places. One
  60. * should be able to cast the line from up into the water, not only fishing whith one's feet wet. :)
  61. *
  62. * TODO: Consider in the future, limiting the maximum height one can be above water, if we start getting
  63. * "orbital fishing" players... xD
  64. */
  65. public final L2FishingZone isInsideFishingZone(int x, int y, int z)
  66. {
  67. for (L2FishingZone temp : _fishingZones)
  68. if (temp.isInsideZone(x, y, temp.getWaterZ() - 10)) return temp;
  69. return null;
  70. }
  71. public final L2WaterZone isInsideWaterZone(int x, int y, int z)
  72. {
  73. for (L2WaterZone temp : _waterZones)
  74. if (temp.isInsideZone(x, y, temp.getWaterZ())) return temp;
  75. return null;
  76. }
  77. }