FishingZoneManager.java 2.5 KB

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