@Override public boolean useAdminCommand(String command, L2PcInstance activeChar) { int teleportIndex = -1; final AutoSpawnInstance blackSpawnInst = AutoSpawnHandler.getInstance().getAutoSpawnInstance(SevenSigns.MAMMON_BLACKSMITH_ID, false); final AutoSpawnInstance merchSpawnInst = AutoSpawnHandler.getInstance().getAutoSpawnInstance(SevenSigns.MAMMON_MERCHANT_ID, false); if (command.startsWith("admin_mammon_find")) { try { if (command.length() > 17) { teleportIndex = Integer.parseInt(command.substring(18)); } } catch (Exception NumberFormatException) { activeChar.sendMessage( "Usage: //mammon_find [teleportIndex] (where 1 = Blacksmith, 2 = Merchant)"); return false; } if (!_isSealValidation) { activeChar.sendPacket(SystemMessageId.SSQ_COMPETITION_UNDERWAY); return false; } if (blackSpawnInst != null) { final L2Npc[] blackInst = blackSpawnInst.getNPCInstanceList(); if (blackInst.length > 0) { final int x1 = blackInst[0].getX(), y1 = blackInst[0].getY(), z1 = blackInst[0].getZ(); activeChar.sendMessage( MessageTable.Messages[1739].getMessage() + x1 + " " + y1 + " " + z1); if (teleportIndex == 1) { activeChar.teleToLocation(x1, y1, z1, true); } } } else { activeChar.sendMessage(1740); } if (merchSpawnInst != null) { final L2Npc[] merchInst = merchSpawnInst.getNPCInstanceList(); if (merchInst.length > 0) { final int x2 = merchInst[0].getX(), y2 = merchInst[0].getY(), z2 = merchInst[0].getZ(); activeChar.sendMessage( MessageTable.Messages[1741].getMessage() + x2 + " " + y2 + " " + z2); if (teleportIndex == 2) { activeChar.teleToLocation(x2, y2, z2, true); } } } else { activeChar.sendMessage(1742); } } else if (command.startsWith("admin_mammon_respawn")) { if (!_isSealValidation) { activeChar.sendPacket(SystemMessageId.SSQ_COMPETITION_UNDERWAY); return true; } if (merchSpawnInst != null) { long merchRespawn = AutoSpawnHandler.getInstance().getTimeToNextSpawn(merchSpawnInst); activeChar.sendMessage( MessageTable.Messages[1743].getExtra(1) + (merchRespawn / 60000) + MessageTable.Messages[1743].getExtra(2)); } else { activeChar.sendMessage(1742); } if (blackSpawnInst != null) { long blackRespawn = AutoSpawnHandler.getInstance().getTimeToNextSpawn(blackSpawnInst); activeChar.sendMessage( MessageTable.Messages[1744].getExtra(1) + (blackRespawn / 60000) + MessageTable.Messages[1744].getExtra(2)); } else { activeChar.sendMessage(1740); } } return true; }
public boolean useAdminCommand(String command, L2PcInstance activeChar) { int npcId = 0; int teleportIndex = -1; AutoSpawnInstance blackSpawnInst = AutoSpawnHandler.getInstance().getAutoSpawnInstance(SevenSigns.MAMMON_BLACKSMITH_ID, false); AutoSpawnInstance merchSpawnInst = AutoSpawnHandler.getInstance().getAutoSpawnInstance(SevenSigns.MAMMON_MERCHANT_ID, false); if (command.startsWith("admin_mammon_find")) { try { if (command.length() > 17) teleportIndex = Integer.parseInt(command.substring(18)); } catch (Exception NumberFormatException) { activeChar.sendMessage( "Usage: //mammon_find [teleportIndex] (where 1 = Blacksmith, 2 = Merchant)"); } if (!_isSealValidation) { activeChar.sendMessage(1738); return true; } if (blackSpawnInst != null) { L2Npc[] blackInst = blackSpawnInst.getNPCInstanceList(); if (blackInst.length > 0) { int x1 = blackInst[0].getX(), y1 = blackInst[0].getY(), z1 = blackInst[0].getZ(); activeChar.sendMessage( MessageTable.Messages[1739].getMessage() + x1 + " " + y1 + " " + z1); if (teleportIndex == 1) activeChar.teleToLocation(x1, y1, z1, true); } } else activeChar.sendMessage(1740); if (merchSpawnInst != null) { L2Npc[] merchInst = merchSpawnInst.getNPCInstanceList(); if (merchInst.length > 0) { int x2 = merchInst[0].getX(), y2 = merchInst[0].getY(), z2 = merchInst[0].getZ(); activeChar.sendMessage( MessageTable.Messages[1741].getMessage() + x2 + " " + y2 + " " + z2); if (teleportIndex == 2) activeChar.teleToLocation(x2, y2, z2, true); } } else activeChar.sendMessage(1742); } else if (command.startsWith("admin_mammon_respawn")) { if (!_isSealValidation) { activeChar.sendMessage(1738); return true; } if (merchSpawnInst != null) { long merchRespawn = AutoSpawnHandler.getInstance().getTimeToNextSpawn(merchSpawnInst); activeChar.sendMessage( MessageTable.Messages[1743].getExtra(1) + (merchRespawn / 60000) + MessageTable.Messages[1743].getExtra(2)); } else activeChar.sendMessage(1742); if (blackSpawnInst != null) { long blackRespawn = AutoSpawnHandler.getInstance().getTimeToNextSpawn(blackSpawnInst); activeChar.sendMessage( MessageTable.Messages[1744].getExtra(1) + (blackRespawn / 60000) + MessageTable.Messages[1744].getExtra(2)); } else activeChar.sendMessage(1740); } else if (command.startsWith("admin_list_spawns")) { try { // admin_list_spawns x[xxxx] x[xx] String[] params = command.split(" "); Pattern pattern = Pattern.compile("[0-9]*"); Matcher regexp = pattern.matcher(params[1]); if (regexp.matches()) npcId = Integer.parseInt(params[1]); else { params[1] = params[1].replace('_', ' '); npcId = NpcTable.getInstance().getTemplateByName(params[1]).npcId; } if (params.length > 2) teleportIndex = Integer.parseInt(params[2]); } catch (Exception e) { activeChar.sendMessage("Command format is //list_spawns <npcId|npc_name> [tele_index]"); } SpawnTable.getInstance().findNPCInstances(activeChar, npcId, teleportIndex); } // Used for testing SystemMessage IDs - Use //msg <ID> else if (command.startsWith("admin_msg")) { int msgId = -1; try { msgId = Integer.parseInt(command.substring(10).trim()); } catch (Exception e) { activeChar.sendMessage("Command format: //msg <SYSTEM_MSG_ID>"); return true; } activeChar.sendPacket(new SystemMessage(msgId)); } return true; }