AdminGeodata.java 5.4 KB

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