AdminGeodata.java 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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.StringTokenizer;
  21. import com.l2jserver.gameserver.GeoData;
  22. import com.l2jserver.gameserver.handler.IAdminCommandHandler;
  23. import com.l2jserver.gameserver.model.L2Object;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. import com.l2jserver.gameserver.network.SystemMessageId;
  26. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  27. import com.l2jserver.gameserver.util.GeoUtils;
  28. /**
  29. * @author -Nemesiss-, HorridoJoho
  30. */
  31. public class AdminGeodata implements IAdminCommandHandler
  32. {
  33. private static final String[] ADMIN_COMMANDS =
  34. {
  35. "admin_geo_pos",
  36. "admin_geo_spawn_pos",
  37. "admin_geo_can_move",
  38. "admin_geo_can_see",
  39. "admin_geogrid",
  40. };
  41. @Override
  42. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  43. {
  44. final StringTokenizer st = new StringTokenizer(command, " ");
  45. final String actualCommand = st.nextToken();
  46. switch (actualCommand.toLowerCase())
  47. {
  48. case "admin_geo_pos":
  49. {
  50. final int worldX = activeChar.getX();
  51. final int worldY = activeChar.getY();
  52. final int worldZ = activeChar.getZ();
  53. final int geoX = GeoData.getInstance().getGeoX(worldX);
  54. final int geoY = GeoData.getInstance().getGeoY(worldY);
  55. if (GeoData.getInstance().hasGeoPos(geoX, geoY))
  56. {
  57. activeChar.sendMessage("WorldX: " + worldX + ", WorldY: " + worldY + ", WorldZ: " + worldZ + ", GeoX: " + geoX + ", GeoY: " + geoY + ", GeoZ: " + GeoData.getInstance().getNearestZ(geoX, geoY, worldZ));
  58. }
  59. else
  60. {
  61. activeChar.sendMessage("There is no geodata at this position.");
  62. }
  63. break;
  64. }
  65. case "admin_geo_spawn_pos":
  66. {
  67. final int worldX = activeChar.getX();
  68. final int worldY = activeChar.getY();
  69. final int worldZ = activeChar.getZ();
  70. final int geoX = GeoData.getInstance().getGeoX(worldX);
  71. final int geoY = GeoData.getInstance().getGeoY(worldY);
  72. if (GeoData.getInstance().hasGeoPos(geoX, geoY))
  73. {
  74. activeChar.sendMessage("WorldX: " + worldX + ", WorldY: " + worldY + ", WorldZ: " + worldZ + ", GeoX: " + geoX + ", GeoY: " + geoY + ", GeoZ: " + GeoData.getInstance().getSpawnHeight(worldX, worldY, worldZ));
  75. }
  76. else
  77. {
  78. activeChar.sendMessage("There is no geodata at this position.");
  79. }
  80. break;
  81. }
  82. case "admin_geo_can_move":
  83. {
  84. final L2Object target = activeChar.getTarget();
  85. if (target != null)
  86. {
  87. if (GeoData.getInstance().canSeeTarget(activeChar, target))
  88. {
  89. activeChar.sendMessage("Can move beeline.");
  90. }
  91. else
  92. {
  93. activeChar.sendMessage("Can not move beeline!");
  94. }
  95. }
  96. else
  97. {
  98. activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
  99. }
  100. break;
  101. }
  102. case "admin_geo_can_see":
  103. {
  104. final L2Object target = activeChar.getTarget();
  105. if (target != null)
  106. {
  107. if (GeoData.getInstance().canSeeTarget(activeChar, target))
  108. {
  109. activeChar.sendMessage("Can see target.");
  110. }
  111. else
  112. {
  113. activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANT_SEE_TARGET));
  114. }
  115. }
  116. else
  117. {
  118. activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
  119. }
  120. break;
  121. }
  122. case "admin_geogrid":
  123. {
  124. GeoUtils.debugGrid(activeChar);
  125. break;
  126. }
  127. }
  128. return true;
  129. }
  130. @Override
  131. public String[] getAdminCommandList()
  132. {
  133. return ADMIN_COMMANDS;
  134. }
  135. }