AdminGeodata.java 3.8 KB

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