AdminPathNode.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  33. {
  34. if (command.equals("admin_pn_info"))
  35. {
  36. final String[] info = PathFinding.getInstance().getStat();
  37. if (info == null)
  38. activeChar.sendMessage("Not supported");
  39. else
  40. for (String msg : info)
  41. activeChar.sendMessage(msg);
  42. }
  43. else if (command.equals("admin_show_path"))
  44. {
  45. }
  46. else if (command.equals("admin_path_debug"))
  47. {
  48. }
  49. else if (command.equals("admin_show_pn"))
  50. {
  51. }
  52. else if (command.equals("admin_find_path"))
  53. {
  54. if (Config.GEODATA < 2)
  55. {
  56. activeChar.sendMessage("PathFinding has not been enabled.");
  57. return true;
  58. }
  59. if (activeChar.getTarget() != null)
  60. {
  61. 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);
  62. if (path == null)
  63. {
  64. activeChar.sendMessage("No Route!");
  65. return true;
  66. }
  67. for (AbstractNodeLoc a : path)
  68. {
  69. activeChar.sendMessage("x:" + a.getX() + " y:" + a.getY() + " z:" + a.getZ());
  70. }
  71. }
  72. else
  73. activeChar.sendMessage("No Target!");
  74. }
  75. return true;
  76. }
  77. public String[] getAdminCommandList()
  78. {
  79. return ADMIN_COMMANDS;
  80. }
  81. }