AdminGeodata.java 5.5 KB

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