AdminGeodata.java 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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.Config;
  21. import com.l2jserver.gameserver.GeoData;
  22. import com.l2jserver.gameserver.handler.IAdminCommandHandler;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. /**
  25. * @author -Nemesiss-
  26. */
  27. public class AdminGeodata implements IAdminCommandHandler
  28. {
  29. private static final String[] ADMIN_COMMANDS =
  30. {
  31. "admin_geo_z",
  32. "admin_geo_type",
  33. "admin_geo_nswe",
  34. "admin_geo_los",
  35. "admin_geo_position",
  36. "admin_geo_bug",
  37. "admin_geo_load",
  38. "admin_geo_unload"
  39. };
  40. @Override
  41. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  42. {
  43. if (Config.GEODATA < 1)
  44. {
  45. activeChar.sendMessage("Geo Engine is Turned Off!");
  46. return true;
  47. }
  48. if (command.equals("admin_geo_z"))
  49. {
  50. activeChar.sendMessage("GeoEngine: Geo_Z = " + GeoData.getInstance().getHeight(activeChar.getX(), activeChar.getY(), activeChar.getZ()) + " Loc_Z = " + activeChar.getZ());
  51. }
  52. else if (command.equals("admin_geo_type"))
  53. {
  54. short type = GeoData.getInstance().getType(activeChar.getX(), activeChar.getY());
  55. activeChar.sendMessage("GeoEngine: Geo_Type = " + type);
  56. short height = GeoData.getInstance().getHeight(activeChar.getX(), activeChar.getY(), activeChar.getZ());
  57. activeChar.sendMessage("GeoEngine: height = " + height);
  58. }
  59. else if (command.equals("admin_geo_nswe"))
  60. {
  61. String result = "";
  62. short nswe = GeoData.getInstance().getNSWE(activeChar.getX(), activeChar.getY(), activeChar.getZ());
  63. if ((nswe & 8) == 0)
  64. {
  65. result += " N";
  66. }
  67. if ((nswe & 4) == 0)
  68. {
  69. result += " S";
  70. }
  71. if ((nswe & 2) == 0)
  72. {
  73. result += " W";
  74. }
  75. if ((nswe & 1) == 0)
  76. {
  77. result += " E";
  78. }
  79. activeChar.sendMessage("GeoEngine: Geo_NSWE -> " + nswe + "->" + result);
  80. }
  81. else if (command.equals("admin_geo_los"))
  82. {
  83. if (activeChar.getTarget() != null)
  84. {
  85. if (GeoData.getInstance().canSeeTargetDebug(activeChar, activeChar.getTarget()))
  86. {
  87. activeChar.sendMessage("GeoEngine: Can See Target");
  88. }
  89. else
  90. {
  91. activeChar.sendMessage("GeoEngine: Can't See Target");
  92. }
  93. }
  94. else
  95. {
  96. activeChar.sendMessage("None Target!");
  97. }
  98. }
  99. else if (command.equals("admin_geo_position"))
  100. {
  101. activeChar.sendMessage("GeoEngine: Your current position: ");
  102. activeChar.sendMessage(".... world coords: x: " + activeChar.getX() + " y: " + activeChar.getY() + " z: " + activeChar.getZ());
  103. activeChar.sendMessage(".... geo position: " + GeoData.getInstance().geoPosition(activeChar.getX(), activeChar.getY()));
  104. }
  105. else if (command.startsWith("admin_geo_load"))
  106. {
  107. String[] v = command.substring(15).split(" ");
  108. if (v.length != 2)
  109. {
  110. activeChar.sendMessage("Usage: //admin_geo_load <regionX> <regionY>");
  111. }
  112. else
  113. {
  114. try
  115. {
  116. byte rx = Byte.parseByte(v[0]);
  117. byte ry = Byte.parseByte(v[1]);
  118. boolean result = GeoData.loadGeodataFile(rx, ry);
  119. if (result)
  120. {
  121. activeChar.sendMessage("GeoEngine: File for region [" + rx + "," + ry + "] loaded succesfuly");
  122. }
  123. else
  124. {
  125. activeChar.sendMessage("GeoEngine: File for region [" + rx + "," + ry + "] couldn't be loaded");
  126. }
  127. }
  128. catch (Exception e)
  129. {
  130. activeChar.sendMessage("You have to write numbers of regions <regionX> <regionY>");
  131. }
  132. }
  133. }
  134. else if (command.startsWith("admin_geo_unload"))
  135. {
  136. String[] v = command.substring(17).split(" ");
  137. if (v.length != 2)
  138. {
  139. activeChar.sendMessage("Usage: //admin_geo_unload <regionX> <regionY>");
  140. }
  141. else
  142. {
  143. try
  144. {
  145. byte rx = Byte.parseByte(v[0]);
  146. byte ry = Byte.parseByte(v[1]);
  147. GeoData.unloadGeodata(rx, ry);
  148. activeChar.sendMessage("GeoEngine: File for region [" + rx + "," + ry + "] unloaded.");
  149. }
  150. catch (Exception e)
  151. {
  152. activeChar.sendMessage("You have to write numbers of regions <regionX> <regionY>");
  153. }
  154. }
  155. }
  156. else if (command.startsWith("admin_geo_bug"))
  157. {
  158. try
  159. {
  160. String comment = command.substring(14);
  161. GeoData.getInstance().addGeoDataBug(activeChar, comment);
  162. }
  163. catch (StringIndexOutOfBoundsException e)
  164. {
  165. activeChar.sendMessage("Usage: //admin_geo_bug you coments here");
  166. }
  167. }
  168. return true;
  169. }
  170. @Override
  171. public String[] getAdminCommandList()
  172. {
  173. return ADMIN_COMMANDS;
  174. }
  175. }