private int getOnlineGMS() { return AdminTable.getInstance().getAllGms(true).size(); }
public class Die extends L2GameServerPacket { private final int _charObjId; private final boolean _canTeleport; private final boolean _sweepable; private L2AccessLevel _access = AdminTable.getInstance().getAccessLevel(0); private L2Clan _clan; private final L2Character _activeChar; private boolean _isJailed; public Die(L2Character cha) { _charObjId = cha.getObjectId(); _activeChar = cha; if (cha.isPlayer()) { final L2PcInstance player = cha.getActingPlayer(); _access = player.getAccessLevel(); _clan = player.getClan(); _isJailed = player.isInJail(); } _canTeleport = cha.canRevive() && !cha.isPendingRevive(); _sweepable = cha.isL2Attackable() && cha.isSweepActive(); } @Override protected final void writeImpl() { writeC(0x00); writeD(_charObjId); writeD(_canTeleport ? 0x01 : 0); if (_canTeleport && (_clan != null) && !_isJailed) { boolean isInCastleDefense = false; boolean isInFortDefense = false; L2SiegeClan siegeClan = null; Castle castle = CastleManager.getInstance().getCastle(_activeChar); Fort fort = FortManager.getInstance().getFort(_activeChar); SiegableHall hall = CHSiegeManager.getInstance().getNearbyClanHall(_activeChar); if ((castle != null) && castle.getSiege().getIsInProgress()) { // siege in progress siegeClan = castle.getSiege().getAttackerClan(_clan); if ((siegeClan == null) && castle.getSiege().checkIsDefender(_clan)) { isInCastleDefense = true; } } else if ((fort != null) && fort.getSiege().getIsInProgress()) { // siege in progress siegeClan = fort.getSiege().getAttackerClan(_clan); if ((siegeClan == null) && fort.getSiege().checkIsDefender(_clan)) { isInFortDefense = true; } } writeD(_clan.getHideoutId() > 0 ? 0x01 : 0x00); // 6d 01 00 00 00 - to hide away writeD( (_clan.getCastleId() > 0) || isInCastleDefense ? 0x01 : 0x00); // 6d 02 00 00 00 - to castle writeD( (TerritoryWarManager.getInstance().getFlagForClan(_clan) != null) || ((siegeClan != null) && !isInCastleDefense && !isInFortDefense && !siegeClan.getFlag().isEmpty()) || ((hall != null) && hall.getSiege().checkIsAttacker(_clan)) ? 0x01 : 0x00); // 6d 03 00 00 00 - to siege HQ writeD(_sweepable ? 0x01 : 0x00); // sweepable (blue glow) writeD(_access.allowFixedRes() ? 0x01 : 0x00); // 6d 04 00 00 00 - to FIXED writeD( (_clan.getFortId() > 0) || isInFortDefense ? 0x01 : 0x00); // 6d 05 00 00 00 - to fortress } else { writeD(0x00); // 6d 01 00 00 00 - to hide away writeD(0x00); // 6d 02 00 00 00 - to castle writeD(0x00); // 6d 03 00 00 00 - to siege HQ writeD(_sweepable ? 0x01 : 0x00); // sweepable (blue glow) writeD(_access.allowFixedRes() ? 0x01 : 0x00); // 6d 04 00 00 00 - to FIXED writeD(0x00); // 6d 05 00 00 00 - to fortress } // TODO: protocol 152 // @formatter:off /* * writeC(0); //show die animation * writeD(0); //agathion ress button * writeD(0); //additional free space */ // @formatter:on } }
@Override public boolean useAdminCommand(String command, L2PcInstance activeChar) { if (command.equals("admin_show_spawns")) { AdminHtml.showAdminHtml(activeChar, "spawns.htm"); } else if (command.equalsIgnoreCase("admin_spawn_debug_menu")) { AdminHtml.showAdminHtml(activeChar, "spawns_debug.htm"); } else if (command.startsWith("admin_spawn_debug_print")) { StringTokenizer st = new StringTokenizer(command, " "); L2Object target = activeChar.getTarget(); if (target instanceof L2Npc) { try { st.nextToken(); int type = Integer.parseInt(st.nextToken()); printSpawn((L2Npc) target, type); if (command.contains("_menu")) { AdminHtml.showAdminHtml(activeChar, "spawns_debug.htm"); } } catch (Exception e) { } } else { activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET); } } else if (command.startsWith("admin_spawn_index")) { StringTokenizer st = new StringTokenizer(command, " "); try { st.nextToken(); int level = Integer.parseInt(st.nextToken()); int from = 0; try { from = Integer.parseInt(st.nextToken()); } catch (NoSuchElementException nsee) { } showMonsters(activeChar, level, from); } catch (Exception e) { AdminHtml.showAdminHtml(activeChar, "spawns.htm"); } } else if (command.equals("admin_show_npcs")) { AdminHtml.showAdminHtml(activeChar, "npcs.htm"); } else if (command.startsWith("admin_npc_index")) { StringTokenizer st = new StringTokenizer(command, " "); try { st.nextToken(); String letter = st.nextToken(); int from = 0; try { from = Integer.parseInt(st.nextToken()); } catch (NoSuchElementException nsee) { } showNpcs(activeChar, letter, from); } catch (Exception e) { AdminHtml.showAdminHtml(activeChar, "npcs.htm"); } } else if (command.startsWith("admin_instance_spawns")) { StringTokenizer st = new StringTokenizer(command, " "); try { st.nextToken(); int instance = Integer.parseInt(st.nextToken()); if (instance >= 300000) { final StringBuilder html = StringUtil.startAppend( 500 + 1000, "<html><table width=\"100%\"><tr><td width=45><button value=\"Main\" action=\"bypass -h admin_admin\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=180><center>", "<font color=\"LEVEL\">Spawns for " + String.valueOf(instance) + "</font>", "</td><td width=45><button value=\"Back\" action=\"bypass -h admin_current_player\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table><br>", "<table width=\"100%\"><tr><td width=200>NpcName</td><td width=70>Action</td></tr>"); int counter = 0; int skiped = 0; Instance inst = InstanceManager.getInstance().getInstance(instance); if (inst != null) { for (L2Npc npc : inst.getNpcs()) { if (!npc.isDead()) { // Only 50 because of client html limitation if (counter < 50) { StringUtil.append( html, "<tr><td>" + npc.getName() + "</td><td>", "<a action=\"bypass -h admin_move_to " + npc.getX() + " " + npc.getY() + " " + npc.getZ() + "\">Go</a>", "</td></tr>"); counter++; } else { skiped++; } } } StringUtil.append( html, "<tr><td>Skipped:</td><td>" + String.valueOf(skiped) + "</td></tr></table></body></html>"); final NpcHtmlMessage ms = new NpcHtmlMessage(); ms.setHtml(html.toString()); activeChar.sendPacket(ms); } else { activeChar.sendMessage("Cannot find instance " + instance); } } else { activeChar.sendMessage("Invalid instance number."); } } catch (Exception e) { activeChar.sendMessage("Usage //instance_spawns <instance_number>"); } } else if (command.startsWith("admin_unspawnall")) { Broadcast.toAllOnlinePlayers( SystemMessage.getSystemMessage(SystemMessageId.NPC_SERVER_NOT_OPERATING)); RaidBossSpawnManager.getInstance().cleanUp(); DayNightSpawnManager.getInstance().cleanUp(); L2World.getInstance().deleteVisibleNpcSpawns(); AdminTable.getInstance().broadcastMessageToGMs("NPC Unspawn completed!"); } else if (command.startsWith("admin_spawnday")) { DayNightSpawnManager.getInstance().spawnDayCreatures(); } else if (command.startsWith("admin_spawnnight")) { DayNightSpawnManager.getInstance().spawnNightCreatures(); } else if (command.startsWith("admin_respawnall") || command.startsWith("admin_spawn_reload")) { // make sure all spawns are deleted RaidBossSpawnManager.getInstance().cleanUp(); DayNightSpawnManager.getInstance().cleanUp(); L2World.getInstance().deleteVisibleNpcSpawns(); // now respawn all NpcData.getInstance().load(); SpawnTable.getInstance().load(); RaidBossSpawnManager.getInstance().load(); AutoSpawnHandler.getInstance().reload(); SevenSigns.getInstance().spawnSevenSignsNPC(); QuestManager.getInstance().reloadAllScripts(); AdminTable.getInstance().broadcastMessageToGMs("NPC Respawn completed!"); } else if (command.startsWith("admin_spawn_monster") || command.startsWith("admin_spawn")) { StringTokenizer st = new StringTokenizer(command, " "); try { String cmd = st.nextToken(); String id = st.nextToken(); int respawnTime = 0; int mobCount = 1; if (st.hasMoreTokens()) { mobCount = Integer.parseInt(st.nextToken()); } if (st.hasMoreTokens()) { respawnTime = Integer.parseInt(st.nextToken()); } if (cmd.equalsIgnoreCase("admin_spawn_once")) { spawnMonster(activeChar, id, respawnTime, mobCount, false); } else { spawnMonster(activeChar, id, respawnTime, mobCount, true); } } catch (Exception e) { // Case of wrong or missing monster data AdminHtml.showAdminHtml(activeChar, "spawns.htm"); } } else if (command.startsWith("admin_list_spawns") || command.startsWith("admin_list_positions")) { int npcId = 0; int teleportIndex = -1; 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 = NpcData.getInstance().getTemplateByName(params[1]).getId(); } if (params.length > 2) { teleportIndex = Integer.parseInt(params[2]); } } catch (Exception e) { activeChar.sendMessage("Command format is //list_spawns <npcId|npc_name> [tele_index]"); } if (command.startsWith("admin_list_positions")) { findNPCInstances(activeChar, npcId, teleportIndex, true); } else { findNPCInstances(activeChar, npcId, teleportIndex, false); } } return true; }