public boolean useAdminCommand(String command, L2PcInstance activeChar) { StringTokenizer st = new StringTokenizer(command, " "); command = st.nextToken(); // Get actual command // Get fort Fort fort = null; int fortId = 0; if (st.hasMoreTokens()) { fortId = Integer.parseInt(st.nextToken()); fort = FortManager.getInstance().getFortById(fortId); } // Get fort if ((fort == null || fortId == 0)) // No fort specified showFortSelectPage(activeChar); else { L2Object target = activeChar.getTarget(); L2PcInstance player = null; if (target instanceof L2PcInstance) player = (L2PcInstance) target; if (command.equalsIgnoreCase("admin_add_fortattacker")) { if (player == null) activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT)); else { if (fort.getSiege().checkIfCanRegister(player)) fort.getSiege().registerAttacker(player, true); } } else if (command.equalsIgnoreCase("admin_clear_fortsiege_list")) { fort.getSiege().clearSiegeClan(); } else if (command.equalsIgnoreCase("admin_endfortsiege")) { fort.getSiege().endSiege(); } else if (command.equalsIgnoreCase("admin_list_fortsiege_clans")) { activeChar.sendMessage(218); } else if (command.equalsIgnoreCase("admin_setfort")) { if (player == null || player.getClan() == null) activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT)); else fort.setOwner(player.getClan(), false); } else if (command.equalsIgnoreCase("admin_removefort")) { L2Clan clan = fort.getOwnerClan(); if (clan != null) fort.removeOwner(true); else activeChar.sendMessage(356); } else if (command.equalsIgnoreCase("admin_spawn_fortdoors")) { fort.resetDoors(); } else if (command.equalsIgnoreCase("admin_startfortsiege")) { fort.getSiege().startSiege(); } showFortSiegePage(activeChar, fort); } return true; }
@Override protected void runImpl() { final L2PcInstance activeChar = getClient().getActiveChar(); if (activeChar == null) return; // Check if the player has a clan if (activeChar.getClan() == null) return; final Castle castle = CastleManager.getInstance().getCastleById(_castleId); if (castle == null) return; // Check if leader of the clan who owns the castle? if ((castle.getOwnerId() != activeChar.getClanId()) || (!activeChar.isClanLeader())) return; final L2Clan clan = ClanTable.getInstance().getClan(_clanId); if (clan == null) return; if (!castle.getSiege().getIsRegistrationOver()) { if (_approved == 1) { if (castle.getSiege().checkIsDefenderWaiting(clan)) castle.getSiege().approveSiegeDefenderClan(_clanId); else return; } else { if ((castle.getSiege().checkIsDefenderWaiting(clan)) || (castle.getSiege().checkIsDefender(clan))) castle.getSiege().removeSiegeClan(_clanId); } } // Update the defender list activeChar.sendPacket(new SiegeDefenderList(castle)); }
@Override protected void runImpl() { final L2PcInstance activeChar = getClient().getActiveChar(); if (activeChar == null) return; // Noblesse can bestow a title to themselves if (activeChar.isNoble() && _target.matches(activeChar.getName())) { activeChar.setTitle(_title); activeChar.sendPacket(SystemMessageId.TITLE_CHANGED); activeChar.broadcastTitleInfo(); } else { // Can the player change/give a title? if ((activeChar.getClanPrivileges() & L2Clan.CP_CL_GIVE_TITLE) != L2Clan.CP_CL_GIVE_TITLE) { activeChar.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT); return; } if (activeChar.getClan().getLevel() < 3) { activeChar.sendPacket(SystemMessageId.CLAN_LVL_3_NEEDED_TO_ENDOWE_TITLE); return; } final L2ClanMember member = activeChar.getClan().getClanMember(_target); if (member != null) { final L2PcInstance playerMember = member.getPlayerInstance(); if (playerMember != null) { playerMember.setTitle(_title); playerMember.sendPacket(SystemMessageId.TITLE_CHANGED); if (activeChar != playerMember) activeChar.sendPacket( SystemMessage.getSystemMessage(SystemMessageId.CLAN_MEMBER_S1_TITLE_CHANGED_TO_S2) .addPcName(playerMember) .addString(_title)); playerMember.broadcastTitleInfo(); } else activeChar.sendPacket(SystemMessageId.TARGET_IS_NOT_FOUND_IN_THE_GAME); } else activeChar.sendPacket(SystemMessageId.TARGET_MUST_BE_IN_CLAN); } }
@Override public boolean useAdminCommand(String command, L2PcInstance activeChar) { // runmod if (command.equals("admin_runmod") || command.equals("admin_instant_move")) activeChar.setTeleMode(1); if (command.equals("admin_runmod tele")) activeChar.setTeleMode(2); if (command.equals("admin_runmod norm")) activeChar.setTeleMode(0); // teleport via panels if (command.equals("admin_tele")) AdminHelpPage.showHelpPage(activeChar, "teleports.htm"); if (command.equals("admin_tele_areas")) AdminHelpPage.showHelpPage(activeChar, "tele/other.htm"); // recalls / goto types if (command.startsWith("admin_goto") || command.startsWith("admin_teleportto")) { StringTokenizer st = new StringTokenizer(command); if (st.countTokens() > 1) { st.nextToken(); String plyr = st.nextToken(); L2PcInstance player = L2World.getInstance().getPlayer(plyr); if (player == null) { activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET); return false; } teleportToCharacter(activeChar, player); } } else if (command.startsWith("admin_recall ")) { try { String targetName = command.substring(13); L2PcInstance player = L2World.getInstance().getPlayer(targetName); if (player == null) { activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET); return false; } teleportCharacter(player, activeChar.getX(), activeChar.getY(), activeChar.getZ()); } catch (StringIndexOutOfBoundsException e) { } } else if (command.startsWith("admin_recall_party")) { try { String targetName = command.substring(19); L2PcInstance player = L2World.getInstance().getPlayer(targetName); if (player == null) { activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET); return false; } if (player.isInParty()) { for (L2PcInstance pm : player.getParty().getPartyMembers()) teleportCharacter(pm, activeChar.getX(), activeChar.getY(), activeChar.getZ()); activeChar.sendMessage("You recall " + player.getName() + "'s party."); } else { activeChar.sendMessage("You recall " + player.getName() + ", but he isn't in a party."); teleportCharacter(player, activeChar.getX(), activeChar.getY(), activeChar.getZ()); } } catch (StringIndexOutOfBoundsException e) { } } else if (command.startsWith("admin_recall_clan")) { try { String targetName = command.substring(18); L2PcInstance player = L2World.getInstance().getPlayer(targetName); if (player == null) { activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET); return false; } L2Clan clan = player.getClan(); if (clan != null) { for (L2PcInstance member : clan.getOnlineMembers()) teleportCharacter(member, activeChar.getX(), activeChar.getY(), activeChar.getZ()); activeChar.sendMessage("You recall " + player.getName() + "'s clan."); } else { activeChar.sendMessage( "You recall " + player.getName() + ", but he isn't a clan member."); teleportCharacter(player, activeChar.getX(), activeChar.getY(), activeChar.getZ()); } } catch (StringIndexOutOfBoundsException e) { } } else if (command.startsWith("admin_move_to")) { try { String val = command.substring(14); teleportTo(activeChar, val); } catch (Exception e) { // Case of empty or missing coordinates AdminHelpPage.showHelpPage(activeChar, "teleports.htm"); } } else if (command.startsWith("admin_sendhome")) { StringTokenizer st = new StringTokenizer(command); if (st.countTokens() > 1) { st.nextToken(); String plyr = st.nextToken(); L2PcInstance player = L2World.getInstance().getPlayer(plyr); if (player == null) { activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET); return false; } sendHome(player); } else { L2Object target = activeChar.getTarget(); L2PcInstance player = null; // if target isn't a player, select yourself as target if (target instanceof L2PcInstance) player = (L2PcInstance) target; else player = activeChar; sendHome(player); } } return true; }
public boolean useAdminCommand(String command, L2PcInstance activeChar) { if (command.equals("admin_current_player")) { showCharacterInfo(activeChar, null); } else if ((command.startsWith("admin_character_list")) || (command.startsWith("admin_character_info"))) { try { String val = command.substring(21); L2PcInstance target = L2World.getInstance().getPlayer(val); if (target != null) showCharacterInfo(activeChar, target); else activeChar.sendPacket(new SystemMessage(SystemMessageId.CHARACTER_DOES_NOT_EXIST)); } catch (StringIndexOutOfBoundsException e) { activeChar.sendMessage(385); } } else if (command.startsWith("admin_show_characters")) { try { String val = command.substring(22); int page = Integer.parseInt(val); listCharacters(activeChar, page); } catch (StringIndexOutOfBoundsException e) { // Case of empty page number activeChar.sendMessage(421); } } else if (command.startsWith("admin_find_character")) { try { String val = command.substring(21); findCharacter(activeChar, val); } catch (StringIndexOutOfBoundsException e) { // Case of empty character name activeChar.sendMessage(392); listCharacters(activeChar, 0); } } else if (command.startsWith("admin_find_ip")) { try { String val = command.substring(14); findCharactersPerIp(activeChar, val); } catch (Exception e) { // Case of empty or malformed IP number activeChar.sendMessage(393); listCharacters(activeChar, 0); } } else if (command.startsWith("admin_find_account")) { try { String val = command.substring(19); findCharactersPerAccount(activeChar, val); } catch (Exception e) { // Case of empty or malformed player name activeChar.sendMessage(391); listCharacters(activeChar, 0); } } else if (command.equals("admin_edit_character")) editCharacter(activeChar); // Karma control commands else if (command.equals("admin_nokarma")) setTargetKarma(activeChar, 0); else if (command.startsWith("admin_setkarma")) { try { String val = command.substring(15); int karma = Integer.parseInt(val); setTargetKarma(activeChar, karma); } catch (Exception e) { if (Config.DEVELOPER) _log.warning("Set karma error: " + e); activeChar.sendMessage(419); } } else if (command.startsWith("admin_setfame")) { try { String val = command.substring(14); int fame = Integer.parseInt(val); L2Object target = activeChar.getTarget(); if (target instanceof L2PcInstance) { L2PcInstance player = (L2PcInstance) target; player.setFame(fame); player.sendPacket(new UserInfo(player)); player.sendPacket(new ExBrExtraUserInfo(player)); L2CoreMessage cm = new L2CoreMessage(MessageTable.Messages[261]); cm.addNumber(fame); cm.sendMessage(player); } else { activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET)); } } catch (Exception e) { if (Config.DEVELOPER) _log.warning("Set Fame error: " + e); activeChar.sendMessage(316); } } else if (command.startsWith("admin_save_modifications")) { try { String val = command.substring(24); adminModifyCharacter(activeChar, val); } catch (StringIndexOutOfBoundsException e) { // Case of empty character name activeChar.sendMessage(113); listCharacters(activeChar, 0); } } else if (command.startsWith("admin_rec")) { try { String val = command.substring(10); int recVal = Integer.parseInt(val); L2Object target = activeChar.getTarget(); L2PcInstance player = null; if (target instanceof L2PcInstance) { player = (L2PcInstance) target; } else { return false; } player.setRecomHave(recVal); player.sendMessage(528); player.broadcastUserInfo(); } catch (Exception e) { activeChar.sendMessage(414); } } else if (command.startsWith("admin_setclass")) { try { String val = command.substring(15); int classidval = Integer.parseInt(val); L2Object target = activeChar.getTarget(); L2PcInstance player = null; if (target instanceof L2PcInstance) player = (L2PcInstance) target; else return false; boolean valid = false; for (ClassId classid : ClassId.values()) if (classidval == classid.getId()) valid = true; if (valid && (player.getClassId().getId() != classidval)) { player.setClassId(classidval); if (!player.isSubClassActive()) player.setBaseClass(classidval); String newclass = player.getTemplate().className; player.store(); L2CoreMessage cm = new L2CoreMessage(MessageTable.Messages[14]); cm.addString(newclass); cm.sendMessage(player); player.broadcastUserInfo(); cm = new L2CoreMessage(MessageTable.Messages[670]); cm.addString(player.getName()); cm.addString(newclass); cm.sendMessage(activeChar); } activeChar.sendMessage(418); } catch (StringIndexOutOfBoundsException e) { AdminHelpPage.showHelpPage(activeChar, "charclasses.htm"); } } else if (command.startsWith("admin_settitle")) { try { String val = command.substring(15); L2Object target = activeChar.getTarget(); L2PcInstance player = null; if (target instanceof L2PcInstance) { player = (L2PcInstance) target; } else { return false; } player.setTitle(val); player.sendMessage(644); player.broadcastTitleInfo(); } catch (StringIndexOutOfBoundsException e) { // Case of empty character title activeChar.sendMessage(584); } } else if (command.startsWith("admin_changename")) { try { String val = command.substring(17); L2Object target = activeChar.getTarget(); L2PcInstance player = null; if (target instanceof L2PcInstance) { player = (L2PcInstance) target; } else { return false; } L2World.getInstance().removeFromAllPlayers(player); player.setName(val); player.store(); L2World.getInstance().addToAllPlayers(player); player.sendMessage(623); player.broadcastUserInfo(); if (player.isInParty()) { // Delete party window for other party members player.getParty().broadcastToPartyMembers(player, new PartySmallWindowDeleteAll()); for (L2PcInstance member : player.getParty().getPartyMembers()) { // And re-add if (member != player) member.sendPacket(new PartySmallWindowAll(member, player.getParty())); } } if (player.getClan() != null) { player.getClan().broadcastClanStatus(); } RegionBBSManager.getInstance().changeCommunityBoard(); } catch (StringIndexOutOfBoundsException e) { // Case of empty character name activeChar.sendMessage(420); } } else if (command.startsWith("admin_setsex")) { L2Object target = activeChar.getTarget(); L2PcInstance player = null; if (target instanceof L2PcInstance) { player = (L2PcInstance) target; } else { return false; } player.getAppearance().setSex(player.getAppearance().getSex() ? false : true); player.sendMessage(621); player.broadcastUserInfo(); player.decayMe(); player.spawnMe(player.getX(), player.getY(), player.getZ()); } else if (command.startsWith("admin_setcolor")) { try { String val = command.substring(15); L2Object target = activeChar.getTarget(); L2PcInstance player = null; if (target instanceof L2PcInstance) { player = (L2PcInstance) target; } else { return false; } player.getAppearance().setNameColor(Integer.decode("0x" + val)); player.sendMessage(622); player.broadcastUserInfo(); } catch (Exception e) { // Case of empty color or invalid hex string activeChar.sendMessage(583); } } else if (command.startsWith("admin_fullfood")) { L2Object target = activeChar.getTarget(); if (target instanceof L2PetInstance) { L2PetInstance targetPet = (L2PetInstance) target; targetPet.setCurrentFed(targetPet.getMaxFed()); targetPet .getOwner() .sendPacket(new SetSummonRemainTime(targetPet.getMaxFed(), targetPet.getCurrentFed())); } else activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET)); } else if (command.startsWith("admin_unpenalty")) { try { StringTokenizer st = new StringTokenizer(command, " "); if (st.countTokens() != 3) { activeChar.sendMessage(364); return false; } st.nextToken(); boolean changeCreateExpiryTime = st.nextToken().equalsIgnoreCase("create"); String playerName = st.nextToken(); L2PcInstance player = null; player = L2World.getInstance().getPlayer(playerName); if (player == null) { Connection con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement ps = con.prepareStatement( "UPDATE characters SET " + (changeCreateExpiryTime ? "clan_create_expiry_time" : "clan_join_expiry_time") + " WHERE char_name=? LIMIT 1"); ps.setString(1, playerName); ps.execute(); } else { // removing penalty if (changeCreateExpiryTime) player.setClanCreateExpiryTime(0); else player.setClanJoinExpiryTime(0); } L2CoreMessage cm = new L2CoreMessage(MessageTable.Messages[470]); cm.addString(playerName); cm.sendMessage(activeChar); } catch (Exception e) { e.printStackTrace(); } } else if (command.startsWith("admin_find_dualbox")) { int multibox = 2; try { String val = command.substring(19); multibox = Integer.parseInt(val); if (multibox < 1) { activeChar.sendMessage(97); return false; } } catch (Exception e) { } findDualbox(activeChar, multibox); } return true; }
@Override public boolean useAdminCommand(String command, L2PcInstance activeChar) { StringTokenizer st = new StringTokenizer(command, " "); command = st.nextToken(); // Get actual command // Get castle Castle castle = null; ClanHall clanhall = null; if (command.startsWith("admin_clanhall")) clanhall = ClanHallManager.getInstance().getClanHallById(Integer.parseInt(st.nextToken())); else if (st.hasMoreTokens()) castle = CastleManager.getInstance().getCastle(st.nextToken()); if (clanhall == null && (castle == null || castle.getCastleId() < 0)) { showCastleSelectPage(activeChar); return true; } L2Object target = activeChar.getTarget(); L2PcInstance player = null; if (target instanceof L2PcInstance) player = (L2PcInstance) target; if (castle != null) { if (command.equalsIgnoreCase("admin_add_attacker")) { if (player == null) activeChar.sendPacket(SystemMessageId.TARGET_IS_INCORRECT); else castle.getSiege().registerAttacker(player); } else if (command.equalsIgnoreCase("admin_add_defender")) { if (player == null) activeChar.sendPacket(SystemMessageId.TARGET_IS_INCORRECT); else castle.getSiege().registerDefender(player); } else if (command.equalsIgnoreCase("admin_add_guard")) { try { int npcId = Integer.parseInt(st.nextToken()); castle.getSiege().getSiegeGuardManager().addSiegeGuard(activeChar, npcId); } catch (Exception e) { activeChar.sendMessage("Usage: //add_guard npcId"); } } else if (command.equalsIgnoreCase("admin_clear_siege_list")) { castle.getSiege().clearSiegeClan(); } else if (command.equalsIgnoreCase("admin_endsiege")) { castle.getSiege().endSiege(); } else if (command.equalsIgnoreCase("admin_list_siege_clans")) { castle.getSiege().listRegisterClan(activeChar); return true; } else if (command.equalsIgnoreCase("admin_move_defenders")) { activeChar.sendPacket(SystemMessage.sendString("Not implemented yet.")); } else if (command.equalsIgnoreCase("admin_setcastle")) { if (player == null || player.getClan() == null) activeChar.sendPacket(SystemMessageId.TARGET_IS_INCORRECT); else if (player.getClan().hasCastle()) activeChar.sendMessage(player.getName() + "'s clan already owns a castle."); else castle.setOwner(player.getClan()); } else if (command.equalsIgnoreCase("admin_removecastle")) { L2Clan clan = ClanTable.getInstance().getClan(castle.getOwnerId()); if (clan != null) castle.removeOwner(clan); else activeChar.sendMessage("Unable to remove castle for this clan."); } else if (command.equalsIgnoreCase("admin_spawn_doors")) { castle.spawnDoors(false); } else if (command.equalsIgnoreCase("admin_startsiege")) { castle.getSiege().startSiege(); } showSiegePage(activeChar, castle.getName()); } else if (clanhall != null) { if (command.equalsIgnoreCase("admin_clanhallset")) { if (player == null || player.getClan() == null) activeChar.sendPacket(SystemMessageId.TARGET_IS_INCORRECT); else if (!ClanHallManager.getInstance().isFree(clanhall.getId())) activeChar.sendMessage("This ClanHall isn't free!"); else if (!player.getClan().hasHideout()) { ClanHallManager.getInstance().setOwner(clanhall.getId(), player.getClan()); if (AuctionManager.getInstance().getAuction(clanhall.getId()) != null) AuctionManager.getInstance().getAuction(clanhall.getId()).deleteAuctionFromDB(); } else activeChar.sendMessage("You have already a ClanHall!"); } else if (command.equalsIgnoreCase("admin_clanhalldel")) { if (!ClanHallManager.getInstance().isFree(clanhall.getId())) { ClanHallManager.getInstance().setFree(clanhall.getId()); AuctionManager.getInstance().initNPC(clanhall.getId()); } else activeChar.sendMessage("This ClanHall is already Free!"); } else if (command.equalsIgnoreCase("admin_clanhallopendoors")) { clanhall.openCloseDoors(true); } else if (command.equalsIgnoreCase("admin_clanhallclosedoors")) { clanhall.openCloseDoors(false); } else if (command.equalsIgnoreCase("admin_clanhallteleportself")) { L2ClanHallZone zone = clanhall.getZone(); if (zone != null) activeChar.teleToLocation(zone.getSpawnLoc(), 0); } showClanHallPage(activeChar, clanhall); } return true; }