/** * @param activeChar * @param player */ private void gatherCharacterInfo(L2PcInstance activeChar, L2PcInstance player, String filename) { String ip = "N/A"; String account = "N/A"; try { String clientInfo = player.getClient().toString(); account = clientInfo.substring(clientInfo.indexOf("Account: ") + 9, clientInfo.indexOf(" - IP: ")); ip = clientInfo.substring(clientInfo.indexOf(" - IP: ") + 7, clientInfo.lastIndexOf("]")); } catch (Exception e) { } NpcHtmlMessage adminReply = new NpcHtmlMessage(5); adminReply.setFile("data/html/admin/" + filename); adminReply.replace("%name%", player.getName()); adminReply.replace("%level%", String.valueOf(player.getLevel())); adminReply.replace( "%clan%", String.valueOf(ClanTable.getInstance().getClan(player.getClanId()))); adminReply.replace("%xp%", String.valueOf(player.getExp())); adminReply.replace("%sp%", String.valueOf(player.getSp())); adminReply.replace("%class%", player.getTemplate().className); adminReply.replace("%ordinal%", String.valueOf(player.getClassId().ordinal())); adminReply.replace("%classid%", String.valueOf(player.getClassId())); adminReply.replace("%x%", String.valueOf(player.getX())); adminReply.replace("%y%", String.valueOf(player.getY())); adminReply.replace("%z%", String.valueOf(player.getZ())); adminReply.replace("%currenthp%", String.valueOf((int) player.getCurrentHp())); adminReply.replace("%maxhp%", String.valueOf(player.getMaxHp())); adminReply.replace("%karma%", String.valueOf(player.getKarma())); adminReply.replace("%currentmp%", String.valueOf((int) player.getCurrentMp())); adminReply.replace("%maxmp%", String.valueOf(player.getMaxMp())); adminReply.replace("%pvpflag%", String.valueOf(player.getPvpFlag())); adminReply.replace("%currentcp%", String.valueOf((int) player.getCurrentCp())); adminReply.replace("%maxcp%", String.valueOf(player.getMaxCp())); adminReply.replace("%pvpkills%", String.valueOf(player.getPvpKills())); adminReply.replace("%pkkills%", String.valueOf(player.getPkKills())); adminReply.replace("%currentload%", String.valueOf(player.getCurrentLoad())); adminReply.replace("%maxload%", String.valueOf(player.getMaxLoad())); adminReply.replace( "%percent%", String.valueOf( Util.roundTo( ((float) player.getCurrentLoad() / (float) player.getMaxLoad()) * 100, 2))); adminReply.replace("%patk%", String.valueOf(player.getPAtk(null))); adminReply.replace("%matk%", String.valueOf(player.getMAtk(null, null))); adminReply.replace("%pdef%", String.valueOf(player.getPDef(null))); adminReply.replace("%mdef%", String.valueOf(player.getMDef(null, null))); adminReply.replace("%accuracy%", String.valueOf(player.getAccuracy())); adminReply.replace("%evasion%", String.valueOf(player.getEvasionRate(null))); adminReply.replace("%critical%", String.valueOf(player.getCriticalHit(null, null))); adminReply.replace("%runspeed%", String.valueOf(player.getRunSpeed())); adminReply.replace("%patkspd%", String.valueOf(player.getPAtkSpd())); adminReply.replace("%matkspd%", String.valueOf(player.getMAtkSpd())); adminReply.replace("%access%", String.valueOf(player.getAccessLevel().getLevel())); adminReply.replace("%account%", account); adminReply.replace("%ip%", ip); activeChar.sendPacket(adminReply); }
@Override public String onTalk(L2Npc npc, L2PcInstance player) { String htmltext = getNoQuestMsg(); QuestState st = player.getQuestState(qn); if (st == null) return htmltext; switch (st.getState()) { case STATE_CREATED: final int classId = player.getClassId().getId(); if (classId != 0x01 && classId != 0x2f && classId != 0x13 && classId != 0x20) htmltext = "30623-02.htm"; else if (player.getLevel() < 39) htmltext = "30623-01.htm"; else htmltext = "30623-03.htm"; break; case STATE_STARTED: int cond = st.getInt("cond"); if (cond == 2) htmltext = "30623-07a.htm"; else if (cond == 3) htmltext = "30623-13.htm"; else if (cond == 4) htmltext = "30623-17.htm"; else if (cond == 5) { htmltext = "30623-18.htm"; st.takeItems(FINAL_ORDER, 1); st.takeItems(EXCURO_SKIN, -1); st.takeItems(KRATOR_SHARD, -1); st.takeItems(GRANDIS_SKIN, -1); st.takeItems(TIMAK_ORC_BELT, -1); st.takeItems(LAKIN_MACE, -1); st.giveItems(MARK_OF_DUELIST, 1); st.rewardExpAndSp(47015, 20000); player.broadcastPacket(new SocialAction(player, 3)); st.playSound(QuestState.SOUND_FINISH); st.exitQuest(false); } break; case STATE_COMPLETED: htmltext = getAlreadyCompletedMsg(); break; } return htmltext; }
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 String onTalk(L2Npc npc, L2PcInstance player) { QuestState st = player.getQuestState(qn); String htmltext = getNoQuestMsg(); if (st == null) return htmltext; switch (st.getState()) { case STATE_CREATED: if (player.getClassId() != ClassId.wizard && player.getClassId() != ClassId.elvenWizard && player.getClassId() != ClassId.darkWizard) htmltext = "30461-01.htm"; else if (player.getLevel() < 35) htmltext = "30461-02.htm"; else htmltext = "30461-03.htm"; break; case STATE_STARTED: int cond = st.getInt("cond"); switch (npc.getNpcId()) { case MIRIEN: if (cond < 14) htmltext = "30461-05.htm"; else if (cond == 14) { htmltext = "30461-06.htm"; st.set("cond", "15"); st.playSound(QuestState.SOUND_MIDDLE); st.takeItems(MIRIEN_SIGIL_1, 1); st.takeItems(SYMBOL_OF_SYLVAIN, 1); st.giveItems(MIRIEN_SIGIL_2, 1); } else if (cond > 14 && cond < 18) htmltext = "30461-07.htm"; else if (cond == 18) { if (!st.hasQuestItems(MIRIEN_INSTRUCTION)) htmltext = "30461-08.htm"; else { if (player.getLevel() < 36) htmltext = "30461-11.htm"; else { htmltext = "30461-12.htm"; st.set("cond", "19"); st.playSound(QuestState.SOUND_MIDDLE); st.takeItems(MIRIEN_INSTRUCTION, 1); st.takeItems(MIRIEN_SIGIL_2, 1); st.takeItems(SYMBOL_OF_JUREK, 1); st.giveItems(MIRIEN_SIGIL_3, 1); } } } else if (cond > 18 && cond < 31) htmltext = "30461-13.htm"; else if (cond == 31) { htmltext = "30461-14.htm"; st.takeItems(MIRIEN_SIGIL_3, 1); st.takeItems(SYMBOL_OF_CRONOS, 1); st.giveItems(MARK_OF_SCHOLAR, 1); st.rewardExpAndSp(80265, 30000); player.broadcastPacket(new SocialAction(player, 3)); st.playSound(QuestState.SOUND_FINISH); st.exitQuest(false); } break; case SYLVAIN: if (cond == 1) htmltext = "30070-01.htm"; else if (cond < 13) htmltext = "30070-03.htm"; else if (cond == 13) { htmltext = "30070-04.htm"; st.set("cond", "14"); st.playSound(QuestState.SOUND_MIDDLE); st.takeItems(CRYSTAL_OF_PURITY_1, 1); st.takeItems(HIGH_PRIEST_SIGIL, 1); st.giveItems(SYMBOL_OF_SYLVAIN, 1); } else if (cond == 14) htmltext = "30070-05.htm"; else if (cond > 14) htmltext = "30070-06.htm"; break; case MARIA: if (cond == 2) htmltext = "30608-01.htm"; else if (cond == 3) htmltext = "30608-03.htm"; else if (cond == 4) { htmltext = "30608-04.htm"; st.set("cond", "5"); st.playSound(QuestState.SOUND_MIDDLE); st.takeItems(LUCAS_LETTER, 1); st.giveItems(MARIA_LETTER_2, 1); } else if (cond == 5) htmltext = "30608-05.htm"; else if (cond == 6) htmltext = "30608-06.htm"; else if (cond == 7) htmltext = "30608-09.htm"; else if (cond == 8) { htmltext = "30608-10.htm"; st.set("cond", "9"); st.playSound(QuestState.SOUND_MIDDLE); st.takeItems(CRETA_PAINTING_1, 1); st.giveItems(CRETA_PAINTING_2, 1); } else if (cond == 9) htmltext = "30608-11.htm"; else if (cond == 10) { htmltext = "30608-12.htm"; st.set("cond", "11"); st.playSound(QuestState.SOUND_MIDDLE); } else if (cond == 11) htmltext = "30608-12.htm"; else if (cond == 12) htmltext = "30608-13.htm"; else if (cond == 13) htmltext = "30608-15.htm"; else if (st.hasAtLeastOneQuestItem(SYMBOL_OF_SYLVAIN, MIRIEN_SIGIL_2)) htmltext = "30608-16.htm"; else if (cond > 18) { if (!st.hasQuestItems(VALKON_REQUEST)) htmltext = "30608-17.htm"; else { htmltext = "30608-18.htm"; st.takeItems(VALKON_REQUEST, 1); st.giveItems(CRYSTAL_OF_PURITY_2, 1); } } break; case JUREK: if (cond == 15) htmltext = "30115-01.htm"; else if (cond == 16) htmltext = "30115-04.htm"; else if (cond == 17) { htmltext = "30115-05.htm"; st.set("cond", "18"); st.playSound(QuestState.SOUND_MIDDLE); st.takeItems(GRAND_MAGISTER_SIGIL, 1); st.takeItems(JUREK_LIST, 1); st.takeItems(MONSTER_EYE_DESTROYER_SKIN, -1); st.takeItems(SHACKLE_SCALP, -1); st.takeItems(SHAMAN_NECKLACE, -1); st.giveItems(SYMBOL_OF_JUREK, 1); } else if (cond == 18) htmltext = "30115-06.htm"; else if (cond > 18) htmltext = "30115-07.htm"; break; case LUCAS: if (cond == 3) { htmltext = "30071-01.htm"; st.set("cond", "4"); st.playSound(QuestState.SOUND_MIDDLE); st.takeItems(MARIA_LETTER_1, 1); st.giveItems(LUCAS_LETTER, 1); } else if (cond > 3 && cond < 9) htmltext = "30071-02.htm"; else if (cond == 9) htmltext = "30071-03.htm"; else if (cond == 10 || cond == 11) htmltext = "30071-05.htm"; else if (cond == 12) htmltext = "30071-06.htm"; else if (cond > 12) htmltext = "30071-07.htm"; break; case CRETA: if (cond == 5) htmltext = "30609-01.htm"; else if (cond == 6) htmltext = "30609-06.htm"; else if (cond == 7) htmltext = "30609-07.htm"; else if (cond > 7 && cond < 13) htmltext = "30609-10.htm"; else if (cond >= 13 && cond < 19) htmltext = "30609-11.htm"; else if (cond == 21) htmltext = "30609-12.htm"; else if (cond > 21) htmltext = "30609-15.htm"; break; case CRONOS: if (cond == 19) htmltext = "30610-01.htm"; else if (cond > 19 && cond < 30) htmltext = "30610-11.htm"; else if (cond == 30) htmltext = "30610-12.htm"; else if (cond == 31) htmltext = "30610-15.htm"; break; case DIETER: if (cond == 20) htmltext = "30111-01.htm"; else if (cond == 21) htmltext = "30111-06.htm"; else if (cond == 22) htmltext = "30111-07.htm"; else if (cond == 23) htmltext = "30111-10.htm"; else if (cond == 24) htmltext = "30111-11.htm"; else if (cond > 24 && cond < 31) htmltext = (!st.hasQuestItems( SCRIPTURE_CHAPTER_1, SCRIPTURE_CHAPTER_2, SCRIPTURE_CHAPTER_3, SCRIPTURE_CHAPTER_4)) ? "30111-12.htm" : "30111-13.htm"; else if (cond == 31) htmltext = "30111-15.htm"; break; case EDROC: if (cond == 23) htmltext = "30230-01.htm"; else if (cond == 24) htmltext = "30230-03.htm"; else if (cond > 24) htmltext = "30230-04.htm"; break; case RAUT: if (cond == 24) htmltext = "30316-01.htm"; else if (cond == 25) htmltext = "30316-04.htm"; else if (cond > 25) htmltext = "30316-05.htm"; break; case TRIFF: if (cond == 25) htmltext = "30611-01.htm"; else if (cond > 25) htmltext = "30611-05.htm"; break; case VALKON: if (st.hasQuestItems(TRIFF_RING)) { if (!st.hasQuestItems(SCRIPTURE_CHAPTER_2)) { if (!st.hasQuestItems(VALKON_REQUEST)) { if (!st.hasQuestItems(CRYSTAL_OF_PURITY_2)) htmltext = "30103-01.htm"; else { htmltext = "30103-06.htm"; st.takeItems(CRYSTAL_OF_PURITY_2, 1); st.giveItems(SCRIPTURE_CHAPTER_2, 1); } } else htmltext = "30103-05.htm"; } else htmltext = "30103-07.htm"; } break; case POITAN: if (cond == 26 || cond == 27) { if (!st.hasQuestItems(POITAN_NOTES)) { htmltext = "30458-01.htm"; st.giveItems(POITAN_NOTES, 1); } else htmltext = "30458-02.htm"; } else if (cond == 28 || cond == 29) htmltext = "30458-03.htm"; else if (cond == 30) htmltext = "30458-04.htm"; break; case CASIAN: if ((cond == 26 || cond == 27) && st.hasQuestItems(POITAN_NOTES)) { if (st.hasQuestItems(SCRIPTURE_CHAPTER_1, SCRIPTURE_CHAPTER_2, SCRIPTURE_CHAPTER_3)) htmltext = "30612-02.htm"; else { htmltext = "30612-01.htm"; if (cond == 26) { st.set("cond", "27"); st.playSound(QuestState.SOUND_MIDDLE); } } } else if (cond == 28) htmltext = "30612-05.htm"; else if (cond == 29) htmltext = "30612-06.htm"; else if (cond == 30) htmltext = "30612-08.htm"; break; } break; case STATE_COMPLETED: htmltext = getAlreadyCompletedMsg(); break; } return htmltext; }