AdminGeodata.java 4.2 KB

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