AdminPathNode.java 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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.handler.admincommandhandlers;
  16. import java.util.List;
  17. import net.sf.l2j.Config;
  18. import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
  19. import net.sf.l2j.gameserver.model.L2World;
  20. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  21. import net.sf.l2j.gameserver.pathfinding.AbstractNodeLoc;
  22. import net.sf.l2j.gameserver.pathfinding.geonodes.GeoPathFinding;
  23. public class AdminPathNode implements IAdminCommandHandler
  24. {
  25. private static final String[] ADMIN_COMMANDS =
  26. {
  27. "admin_pn_info",
  28. "admin_show_path",
  29. "admin_path_debug",
  30. "admin_show_pn",
  31. "admin_find_path",
  32. };
  33. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  34. {
  35. if (command.equals("admin_pn_info"))
  36. {
  37. }
  38. else if (command.equals("admin_show_path"))
  39. {
  40. }
  41. else if (command.equals("admin_path_debug"))
  42. {
  43. }
  44. else if (command.equals("admin_show_pn"))
  45. {
  46. }
  47. else if (command.equals("admin_find_path"))
  48. {
  49. if (Config.GEODATA < 2)
  50. {
  51. activeChar.sendMessage("PathFinding has not been enabled.");
  52. return true;
  53. }
  54. if (activeChar.getTarget() != null)
  55. {
  56. int gx = (activeChar.getX() - L2World.MAP_MIN_X) >> 4;
  57. int gy = (activeChar.getY() - L2World.MAP_MIN_Y) >> 4;
  58. int gtx = (activeChar.getTarget().getX() - L2World.MAP_MIN_X) >> 4;
  59. int gty = (activeChar.getTarget().getY() - L2World.MAP_MIN_Y) >> 4;
  60. List<AbstractNodeLoc> path = GeoPathFinding.getInstance().findPath(gx, gy, (short) activeChar.getZ(), gtx, gty, (short) activeChar.getTarget().getZ());
  61. if (path == null)
  62. {
  63. activeChar.sendMessage("No Route!");
  64. return true;
  65. }
  66. for (AbstractNodeLoc a : path)
  67. {
  68. activeChar.sendMessage("x:" + a.getX() + " y:" + a.getY() + " z:" + a.getZ());
  69. }
  70. }
  71. else
  72. activeChar.sendMessage("No Target!");
  73. }
  74. return true;
  75. }
  76. public String[] getAdminCommandList()
  77. {
  78. return ADMIN_COMMANDS;
  79. }
  80. }