AdminPathNode.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Copyright (C) 2004-2015 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J DataPack is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package handlers.admincommandhandlers;
  20. import java.util.List;
  21. import com.l2jserver.Config;
  22. import com.l2jserver.gameserver.handler.IAdminCommandHandler;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.pathfinding.AbstractNodeLoc;
  25. import com.l2jserver.gameserver.pathfinding.PathFinding;
  26. public class AdminPathNode implements IAdminCommandHandler
  27. {
  28. private static final String[] ADMIN_COMMANDS =
  29. {
  30. "admin_pn_info",
  31. "admin_show_path",
  32. "admin_path_debug",
  33. "admin_show_pn",
  34. "admin_find_path",
  35. };
  36. @Override
  37. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  38. {
  39. if (command.equals("admin_pn_info"))
  40. {
  41. final String[] info = PathFinding.getInstance().getStat();
  42. if (info == null)
  43. {
  44. activeChar.sendMessage("Not supported");
  45. }
  46. else
  47. {
  48. for (String msg : info)
  49. {
  50. activeChar.sendMessage(msg);
  51. }
  52. }
  53. }
  54. else if (command.equals("admin_show_path"))
  55. {
  56. }
  57. else if (command.equals("admin_path_debug"))
  58. {
  59. }
  60. else if (command.equals("admin_show_pn"))
  61. {
  62. }
  63. else if (command.equals("admin_find_path"))
  64. {
  65. if (Config.PATHFINDING == 0)
  66. {
  67. activeChar.sendMessage("PathFinding is disabled.");
  68. return true;
  69. }
  70. if (activeChar.getTarget() != null)
  71. {
  72. 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);
  73. if (path == null)
  74. {
  75. activeChar.sendMessage("No Route!");
  76. return true;
  77. }
  78. for (AbstractNodeLoc a : path)
  79. {
  80. activeChar.sendMessage("x:" + a.getX() + " y:" + a.getY() + " z:" + a.getZ());
  81. }
  82. }
  83. else
  84. {
  85. activeChar.sendMessage("No Target!");
  86. }
  87. }
  88. return true;
  89. }
  90. @Override
  91. public String[] getAdminCommandList()
  92. {
  93. return ADMIN_COMMANDS;
  94. }
  95. }