AdminPathNode.java 2.6 KB

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