/* * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that * it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If * not, see <http://www.gnu.org/licenses/>. */ package silentium.scripts.handlers.admin; import silentium.gameserver.configs.MainConfig; import silentium.gameserver.geo.GeoData; import silentium.gameserver.handler.IAdminCommandHandler; import silentium.gameserver.model.actor.instance.L2PcInstance; import silentium.gameserver.network.clientpackets.Say2; /** * @author -Nemesiss- */ public class AdminGeodata implements IAdminCommandHandler { private static final String[] ADMIN_COMMANDS = { "admin_geo_z", "admin_geo_type", "admin_geo_nswe", "admin_geo_los", "admin_geo_position", "admin_geo_bug", "admin_geo_load", "admin_geo_unload" }; @Override public boolean useAdminCommand(final String command, final L2PcInstance activeChar) { if (MainConfig.GEODATA < 1) { activeChar.sendChatMessage(0, Say2.ALL, "SYS", "GeoEngine is actually turned off."); return true; } if ("admin_geo_z".equals(command)) activeChar.sendChatMessage(0, Say2.ALL, "SYS", "GeoEngine: Geo_Z = " + GeoData.getInstance().getHeight(activeChar.getX(), activeChar.getY(), activeChar.getZ()) + " Loc_Z = " + activeChar.getZ()); else if ("admin_geo_type".equals(command)) { final short type = GeoData.getInstance().getType(activeChar.getX(), activeChar.getY()); activeChar.sendChatMessage(0, Say2.ALL, "SYS", "GeoEngine: Geo_Type = " + type); final short height = GeoData.getInstance().getHeight(activeChar.getX(), activeChar.getY(), activeChar.getZ()); activeChar.sendChatMessage(0, Say2.ALL, "SYS", "GeoEngine: height = " + height); } else if ("admin_geo_nswe".equals(command)) { String result = ""; final short nswe = GeoData.getInstance().getNSWE(activeChar.getX(), activeChar.getY(), activeChar.getZ()); if ((nswe & 8) == 0) result += " N"; if ((nswe & 4) == 0) result += " S"; if ((nswe & 2) == 0) result += " W"; if ((nswe & 1) == 0) result += " E"; activeChar.sendChatMessage(0, Say2.ALL, "SYS", "GeoEngine: Geo_NSWE -> " + nswe + "->" + result); } else if ("admin_geo_los".equals(command)) { if (activeChar.getTarget() != null) { if (GeoData.getInstance().canSeeTargetDebug(activeChar, activeChar.getTarget())) activeChar.sendChatMessage(0, Say2.ALL, "SYS", "GeoEngine: Can See Target"); else activeChar.sendChatMessage(0, Say2.ALL, "SYS", "GeoEngine: Can't See Target"); } else activeChar.sendChatMessage(0, Say2.ALL, "SYS", "None Target!"); } else if ("admin_geo_position".equals(command)) { activeChar.sendChatMessage(0, Say2.ALL, "SYS", "GeoEngine: Your current position: "); activeChar.sendChatMessage(0, Say2.ALL, "SYS", ".... world coords: x: " + activeChar.getX() + " y: " + activeChar.getY() + " z: " + activeChar.getZ()); activeChar.sendChatMessage(0, Say2.ALL, "SYS", ".... geo position: " + GeoData.getInstance().geoPosition(activeChar.getX(), activeChar.getY())); } else if (command.startsWith("admin_geo_load")) { final String[] v = command.substring(15).split(" "); if (v.length != 2) activeChar.sendChatMessage(0, Say2.ALL, "SYS", "Usage: //admin_geo_load <regionX> <regionY>"); else { try { final byte rx = Byte.parseByte(v[0]); final byte ry = Byte.parseByte(v[1]); final boolean result = GeoData.loadGeodataFile(rx, ry); if (result) activeChar.sendChatMessage(0, Say2.ALL, "SYS", "GeoEngine: File for region [" + rx + ',' + ry + "] loaded succesfuly"); else activeChar.sendChatMessage(0, Say2.ALL, "SYS", "GeoEngine: File for region [" + rx + ',' + ry + "] couldn't be loaded"); } catch (Exception e) { activeChar.sendChatMessage(0, Say2.ALL, "SYS", "You have to write numbers of regions <regionX> <regionY>"); } } } else if (command.startsWith("admin_geo_unload")) { final String[] v = command.substring(17).split(" "); if (v.length != 2) activeChar.sendChatMessage(0, Say2.ALL, "SYS", "Usage: //admin_geo_unload <regionX> <regionY>"); else { try { final byte rx = Byte.parseByte(v[0]); final byte ry = Byte.parseByte(v[1]); GeoData.unloadGeodata(rx, ry); activeChar.sendChatMessage(0, Say2.ALL, "SYS", "GeoEngine: File for region [" + rx + ',' + ry + "] unloaded."); } catch (Exception e) { activeChar.sendChatMessage(0, Say2.ALL, "SYS", "You have to write numbers of regions <regionX> <regionY>"); } } } else if (command.startsWith("admin_geo_bug")) { try { final String comment = command.substring(14); GeoData.getInstance().addGeoDataBug(activeChar, comment); } catch (StringIndexOutOfBoundsException e) { activeChar.sendChatMessage(0, Say2.ALL, "SYS", "Usage: //admin_geo_bug you coments here"); } } return true; } @Override public String[] getAdminCommandList() { return ADMIN_COMMANDS; } }