AdminPathNode.java 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. "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. if(command.equals("admin_pn_info"))
  34. {
  35. }
  36. else if(command.equals("admin_show_path"))
  37. {
  38. }
  39. else if(command.equals("admin_path_debug"))
  40. {
  41. }
  42. else if(command.equals("admin_show_pn"))
  43. {
  44. }
  45. else if(command.equals("admin_find_path"))
  46. {
  47. if (Config.GEODATA < 2)
  48. {
  49. activeChar.sendMessage("PathFinding has not been enabled.");
  50. return true;
  51. }
  52. if (activeChar.getTarget() != null)
  53. {
  54. int gx = (activeChar.getX() - L2World.MAP_MIN_X) >> 4;
  55. int gy = (activeChar.getY() - L2World.MAP_MIN_Y) >> 4;
  56. int gtx = (activeChar.getTarget().getX() - L2World.MAP_MIN_X) >> 4;
  57. int gty = (activeChar.getTarget().getY() - L2World.MAP_MIN_Y) >> 4;
  58. List<AbstractNodeLoc> path = GeoPathFinding.getInstance().findPath(gx, gy, (short)activeChar.getZ(), gtx, gty, (short)activeChar.getTarget().getZ());
  59. if (path == null)
  60. {
  61. activeChar.sendMessage("No Route!");
  62. return true;
  63. }
  64. for(AbstractNodeLoc a : path)
  65. {
  66. activeChar.sendMessage("x:"+a.getX()+" y:"+a.getY()+" z:"+a.getZ());
  67. }
  68. }
  69. else
  70. activeChar.sendMessage("No Target!");
  71. }
  72. return true;
  73. }
  74. public String[] getAdminCommandList() {
  75. return ADMIN_COMMANDS;
  76. }
  77. }