private final String funcConfirmHtml( final L2PcInstance player, final L2Npc npc, final Castle castle, final int func, final int level) { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) { final NpcHtmlMessage html; final String fstring = (func == Castle.FUNC_TELEPORT) ? "9" : "10"; if (level == 0) { html = getHtmlPacket(player, npc, "castleresetdeco.html"); html.replace("%AgitDecoSubmit%", Integer.toString(func)); } else if ((castle.getFunction(func) != null) && (castle.getFunction(func).getLvl() == level)) { html = getHtmlPacket(player, npc, "castledecoalreadyset.html"); html.replace("%AgitDecoEffect%", "<fstring p1=\"" + level + "\">" + fstring + "</fstring>"); } else { html = getHtmlPacket(player, npc, "castledeco-0" + func + ".html"); html.replace( "%AgitDecoCost%", "<fstring p1=\"" + getFunctionFee(func, level) + "\" p2=\"" + (getFunctionRatio(func) / 86400000) + "\">6</fstring>"); html.replace("%AgitDecoEffect%", "<fstring p1=\"" + level + "\">" + fstring + "</fstring>"); html.replace("%AgitDecoSubmit%", func + " " + level); } player.sendPacket(html); return null; } return "chamberlain-21.html"; }
private void showFortSiegePage(L2PcInstance activeChar, Fort fort) { final NpcHtmlMessage adminReply = new NpcHtmlMessage(); adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/fort.htm"); // L2JTW uses fort.getCName() instead of fort.getName() adminReply.replace("%fortName%", fort.getName()); adminReply.replace("%fortId%", String.valueOf(fort.getResidenceId())); activeChar.sendPacket(adminReply); }
private void showFortSelectPage(L2PcInstance activeChar) { int i = 0; final NpcHtmlMessage adminReply = new NpcHtmlMessage(); adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/forts.htm"); final List<Fort> forts = FortManager.getInstance().getForts(); final StringBuilder cList = new StringBuilder(forts.size() * 100); for (Fort fort : forts) { if (fort != null) { // L2JTW uses fort.getCName() instead of fort.getName() StringUtil.append( cList, "<td fixwidth=90><a action=\"bypass -h admin_fortsiege ", String.valueOf(fort.getResidenceId()), "\">", fort.getName(), " id: ", String.valueOf(fort.getResidenceId()), "</a></td>"); i++; } // L2JTW: if (i > 0) if (i > 2) { cList.append("</tr><tr>"); i = 0; } } adminReply.replace("%forts%", cList.toString()); activeChar.sendPacket(adminReply); }
private void showSiegeTimePage(L2PcInstance activeChar) { final NpcHtmlMessage adminReply = new NpcHtmlMessage(); adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/territorywartime.htm"); adminReply.replace( "%time%", TerritoryWarManager.getInstance().getTWStart().getTime().toString()); activeChar.sendPacket(adminReply); }
@Override public boolean useBypass(String command, L2PcInstance activeChar, L2Character target) { if (!target.isNpc()) { return false; } final L2Npc npc = (L2Npc) target; final NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId()); { if (npc.getCastle().getOwnerId() > 0) { html.setFile(activeChar.getHtmlPrefix(), "data/html/territorystatus.htm"); L2Clan clan = ClanTable.getInstance().getClan(npc.getCastle().getOwnerId()); html.replace("%clanname%", clan.getName()); html.replace("%clanleadername%", clan.getLeaderName()); } else { html.setFile(activeChar.getHtmlPrefix(), "data/html/territorynoclan.htm"); } } html.replace("%castlename%", npc.getCastle().getName()); html.replace("%taxpercent%", "" + npc.getCastle().getTaxPercent()); html.replace("%objectId%", String.valueOf(npc.getObjectId())); { if (npc.getCastle().getResidenceId() > 6) { html.replace("%territory%", "The Kingdom of Elmore"); } else { html.replace("%territory%", "The Kingdom of Aden"); } } activeChar.sendPacket(html); return true; }
@Override public void onBypassFeedback(L2PcInstance player, String command) { if (command.startsWith("1stClass")) { showHtmlMenu(player, getObjectId(), 1); } else if (command.startsWith("2ndClass")) { showHtmlMenu(player, getObjectId(), 2); } else if (command.startsWith("3rdClass")) { showHtmlMenu(player, getObjectId(), 3); } else if (command.startsWith("change_class")) { int val = Integer.parseInt(command.substring(13)); if (checkAndChangeClass(player, val)) { NpcHtmlMessage html = new NpcHtmlMessage(getObjectId()); html.setFile(player.getHtmlPrefix(), "data/html/classmaster/ok.htm"); html.replace("%name%", CharTemplateTable.getInstance().getClassNameById(val)); player.sendPacket(html); } } else if (command.startsWith("become_noble")) { if (!player.isNoble()) { player.setNoble(true); player.sendPacket(new UserInfo(player)); player.sendPacket(new ExBrExtraUserInfo(player)); NpcHtmlMessage html = new NpcHtmlMessage(getObjectId()); html.setFile(player.getHtmlPrefix(), "data/html/classmaster/nobleok.htm"); player.sendPacket(html); } } else if (command.startsWith("learn_skills")) { player.giveAvailableSkills(Config.AUTO_LEARN_FS_SKILLS, true); } else if (command.startsWith("increase_clan_level")) { if (player.getClan() == null || !player.isClanLeader()) { NpcHtmlMessage html = new NpcHtmlMessage(getObjectId()); html.setFile(player.getHtmlPrefix(), "data/html/classmaster/noclanleader.htm"); player.sendPacket(html); } else if (player.getClan().getLevel() >= 5) { NpcHtmlMessage html = new NpcHtmlMessage(getObjectId()); html.setFile(player.getHtmlPrefix(), "data/html/classmaster/noclanlevel.htm"); player.sendPacket(html); } else { player.getClan().changeLevel(5); } } else { super.onBypassFeedback(player, command); } }
@Override public boolean useBypass(String command, L2PcInstance activeChar, L2Character target) { String htmlPath = command.substring(4).trim(); if (htmlPath.isEmpty()) { _log.warning("Player " + activeChar.getName() + " sent empty link html!"); return false; } if (htmlPath.contains("..")) { _log.warning("Player " + activeChar.getName() + " sent invalid link html: " + htmlPath); return false; } String filename = "html/" + htmlPath; final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0); html.setFile(activeChar.getHtmlPrefix(), filename); html.replace("%objectId%", String.valueOf(target != null ? target.getObjectId() : 0)); activeChar.sendPacket(html); return true; }
@Override public void showChatWindow(L2PcInstance player, int val) { player.sendPacket(ActionFailed.STATIC_PACKET); String filename = "data/html/castlemagician/magician-no.htm"; int condition = validateCondition(player); if (condition > COND_ALL_FALSE) { if (condition == COND_BUSY_BECAUSE_OF_SIEGE) filename = "data/html/castlemagician/magician-busy.htm"; // Busy because of siege else if (condition == COND_OWNER) // Clan owns castle { if (val == 0) filename = "data/html/castlemagician/magician.htm"; else filename = "data/html/castlemagician/magician-" + val + ".htm"; } } NpcHtmlMessage html = new NpcHtmlMessage(getObjectId()); html.setFile(player.getHtmlPrefix(), filename); html.replace("%objectId%", String.valueOf(getObjectId())); player.sendPacket(html); }
private final void funcReplace( final Castle castle, final NpcHtmlMessage html, final int func, final String str) { final CastleFunction function = castle.getFunction(func); if (function == null) { html.replace("%" + str + "Depth%", "<fstring>4</fstring>"); html.replace("%" + str + "Cost%", ""); html.replace("%" + str + "Expire%", "<fstring>4</fstring>"); html.replace("%" + str + "Reset%", ""); } else { final String fstring = ((func == Castle.FUNC_SUPPORT) || (func == Castle.FUNC_TELEPORT)) ? "9" : "10"; final Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(function.getEndTime()); html.replace( "%" + str + "Depth%", "<fstring p1=\"" + function.getLvl() + "\">" + fstring + "</fstring>"); html.replace( "%" + str + "Cost%", "<fstring p1=\"" + function.getLease() + "\" p2=\"" + (function.getRate() / 86400000) + "\">6</fstring>"); html.replace( "%" + str + "Expire%", "<fstring p1=\"" + calendar.get(Calendar.DATE) + "\" p2=\"" + (calendar.get(Calendar.MONTH) + 1) + "\" p3=\"" + calendar.get(Calendar.YEAR) + "\">5</fstring>"); html.replace( "%" + str + "Reset%", "[<a action=\"bypass -h Quest CastleChamberlain " + str + " 0\">Deactivate</a>]"); } }
@Override public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) { final Castle castle = npc.getCastle(); final StringTokenizer st = new StringTokenizer(event, " "); String htmltext = null; switch (st.nextToken()) { case "chamberlain-01.html": case "manor-help-01.html": case "manor-help-02.html": case "manor-help-03.html": case "manor-help-04.html": { htmltext = event; break; } case "fort_status": { if (npc.isMyLord(player)) { final StringBuilder sb = new StringBuilder(); final List<Integer> fort = FORTRESS.get(castle.getResidenceId()); for (int id : fort) { final Fort fortress = FortManager.getInstance().getFortById(id); final int fortId = fortress.getResidenceId(); final String fortType = (fortId < 112) ? "1300133" : "1300134"; final String fortStatus; switch (fortress.getFortState()) { case 1: fortStatus = "1300122"; break; case 2: fortStatus = "1300124"; break; default: fortStatus = "1300123"; break; } sb.append("<fstring>1300" + fortId + "</fstring>"); sb.append(" (<fstring>" + fortType + "</fstring>)"); sb.append( " : <font color=\"00FFFF\"><fstring>" + fortStatus + "</fstring></font><br>"); } final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-28.html"); html.replace("%list%", sb.toString()); player.sendPacket(html); } else { htmltext = "chamberlain-21.html"; } break; } case "siege_functions": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) { if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else if (!isDomainFortressInContractStatus(castle.getResidenceId())) { htmltext = "chamberlain-27.html"; } else if (!SevenSigns.getInstance().isCompResultsPeriod()) { htmltext = "chamberlain-26.html"; } else { htmltext = "chamberlain-12.html"; } } else { htmltext = "chamberlain-21.html"; } break; } case "manage_doors": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) { if (st.hasMoreTokens()) { final StringBuilder sb = new StringBuilder(); final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-13.html"); html.replace("%type%", st.nextToken()); while (st.hasMoreTokens()) { sb.append(" " + st.nextToken()); } html.replace("%doors%", sb.toString()); player.sendPacket(html); } else { htmltext = npc.getId() + "-du.html"; } } else { htmltext = "chamberlain-21.html"; } break; } case "upgrade_doors": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) { final int type = Integer.parseInt(st.nextToken()); final int level = Integer.parseInt(st.nextToken()); final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-14.html"); html.replace("%gate_price%", Integer.toString(getDoorUpgradePrice(type, level))); html.replace("%event%", event.substring("upgrade_doors".length() + 1)); player.sendPacket(html); } else { htmltext = "chamberlain-21.html"; } break; } case "upgrade_doors_confirm": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) { if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else { final int type = Integer.parseInt(st.nextToken()); final int level = Integer.parseInt(st.nextToken()); final int price = getDoorUpgradePrice(type, level); final int[] doors = new int[2]; for (int i = 0; i <= st.countTokens(); i++) { doors[i] = Integer.parseInt(st.nextToken()); } final L2DoorInstance door = castle.getDoor(doors[0]); if (door != null) { final int currentLevel = door.getStat().getUpgradeHpRatio(); if (currentLevel >= level) { final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-15.html"); html.replace("%doorlevel%", Integer.toString(currentLevel)); player.sendPacket(html); } else if (player.getAdena() >= price) { takeItems(player, Inventory.ADENA_ID, price); for (int doorId : doors) { castle.setDoorUpgrade(doorId, level, true); } htmltext = "chamberlain-16.html"; } else { htmltext = "chamberlain-09.html"; } } } } else { htmltext = "chamberlain-21.html"; } break; } case "manage_trap": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) { if (st.hasMoreTokens()) { final NpcHtmlMessage html; if (castle.getName().equalsIgnoreCase("aden")) { html = getHtmlPacket(player, npc, "chamberlain-17a.html"); } else { html = getHtmlPacket(player, npc, "chamberlain-17.html"); } html.replace("%trapIndex%", st.nextToken()); player.sendPacket(html); } else { htmltext = npc.getId() + "-tu.html"; } } else { htmltext = "chamberlain-21.html"; } break; } case "upgrade_trap": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) { final String trapIndex = st.nextToken(); final int level = Integer.parseInt(st.nextToken()); final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-18.html"); html.replace("%trapIndex%", trapIndex); html.replace("%level%", Integer.toString(level)); html.replace("%dmgzone_price%", Integer.toString(getTrapUpgradePrice(level))); player.sendPacket(html); } else { htmltext = "chamberlain-21.html"; } break; } case "upgrade_trap_confirm": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) { if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else { final int trapIndex = Integer.parseInt(st.nextToken()); final int level = Integer.parseInt(st.nextToken()); final int price = getTrapUpgradePrice(level); final int currentLevel = castle.getTrapUpgradeLevel(trapIndex); if (currentLevel >= level) { final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-19.html"); html.replace("%dmglevel%", Integer.toString(currentLevel)); player.sendPacket(html); } else if (player.getAdena() >= price) { takeItems(player, Inventory.ADENA_ID, price); castle.setTrapUpgrade(trapIndex, level, true); htmltext = "chamberlain-20.html"; } else { htmltext = "chamberlain-09.html"; } } } else { htmltext = "chamberlain-21.html"; } break; } case "receive_report": { if (npc.isMyLord(player)) { if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-07.html"; } else { final L2Clan clan = ClanTable.getInstance().getClan(castle.getOwnerId()); final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-02.html"); html.replace("%clanleadername%", clan.getLeaderName()); html.replace("%clanname%", clan.getName()); html.replace("%castlename%", String.valueOf(1001000 + castle.getResidenceId())); switch (SevenSigns.getInstance().getCurrentPeriod()) { case SevenSigns.PERIOD_COMP_RECRUITING: html.replace("%ss_event%", "1000509"); break; case SevenSigns.PERIOD_COMPETITION: html.replace("%ss_event%", "1000507"); break; case SevenSigns.PERIOD_SEAL_VALIDATION: case SevenSigns.PERIOD_COMP_RESULTS: html.replace("%ss_event%", "1000508"); break; } html.replace("%ss_avarice%", getSealOwner(1)); html.replace("%ss_gnosis%", getSealOwner(2)); html.replace("%ss_strife%", getSealOwner(3)); player.sendPacket(html); } } else { htmltext = "chamberlain-21.html"; } break; } case "manage_tax": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_TAXES)) { if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else { final NpcHtmlMessage html = getHtmlPacket(player, npc, "castlesettaxrate.html"); html.replace("%tax_rate%", Integer.toString(castle.getTaxPercent())); html.replace("%next_tax_rate%", "0"); // TODO: Implement me! html.replace("%tax_limit%", Integer.toString(getTaxLimit())); player.sendPacket(html); } } else if (isOwner(player, npc)) { final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-03.html"); html.replace("%tax_rate%", Integer.toString(castle.getTaxPercent())); html.replace("%next_tax_rate%", "0"); // TODO: Implement me! player.sendPacket(html); } else { htmltext = "chamberlain-21.html"; } break; } case "set_tax": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_TAXES)) { if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else { final NpcHtmlMessage html; final int tax = (st.hasMoreTokens()) ? Integer.parseInt(st.nextToken()) : 0; final int taxLimit = getTaxLimit(); if (tax > taxLimit) { html = getHtmlPacket(player, npc, "castletoohightaxrate.html"); html.replace("%tax_limit%", Integer.toString(taxLimit)); } else { castle.setTaxPercent(tax); html = getHtmlPacket(player, npc, "castleaftersettaxrate.html"); html.replace("%next_tax_rate%", Integer.toString(tax)); } player.sendPacket(html); } } else { htmltext = "chamberlain-21.html"; } break; } case "manage_vault": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_TAXES)) { long seedIncome = 0; if (Config.ALLOW_MANOR) { for (SeedProduction sp : CastleManorManager.getInstance() .getSeedProduction(castle.getResidenceId(), false)) { final long diff = sp.getStartAmount() - sp.getAmount(); if (diff != 0) { seedIncome += diff * sp.getPrice(); } } } final NpcHtmlMessage html = getHtmlPacket(player, npc, "castlemanagevault.html"); html.replace("%tax_income%", Util.formatAdena(castle.getTreasury())); html.replace("%tax_income_reserved%", "0"); // TODO: Implement me! html.replace("%seed_income%", Util.formatAdena(seedIncome)); player.sendPacket(html); } else { htmltext = "chamberlain-21.html"; } break; } case "deposit": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_TAXES)) { final long amount = (st.hasMoreTokens()) ? Long.parseLong(st.nextToken()) : 0; if ((amount > 0) && (amount < Inventory.MAX_ADENA)) { if (player.getAdena() >= amount) { takeItems(player, Inventory.ADENA_ID, amount); castle.addToTreasuryNoTax(amount); } else { player.sendPacket(SystemMessageId.YOU_NOT_ENOUGH_ADENA); } } htmltext = "chamberlain-01.html"; } else { htmltext = "chamberlain-21.html"; } break; } case "withdraw": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_TAXES)) { final long amount = (st.hasMoreTokens()) ? Long.parseLong(st.nextToken()) : 0; if (amount <= castle.getTreasury()) { castle.addToTreasuryNoTax((-1) * amount); giveAdena(player, amount, false); htmltext = "chamberlain-01.html"; } else { final NpcHtmlMessage html = getHtmlPacket(player, npc, "castlenotenoughbalance.html"); html.replace("%tax_income%", Util.formatAdena(castle.getTreasury())); html.replace("%withdraw_amount%", Util.formatAdena(amount)); player.sendPacket(html); } } else { htmltext = "chamberlain-21.html"; } break; } case "manage_functions": { if (!isOwner(player, npc)) { htmltext = "chamberlain-21.html"; } else if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else { htmltext = "chamberlain-23.html"; } break; } case "banish_foreigner_show": { if (!isOwner(player, npc) || !player.hasClanPrivilege(ClanPrivilege.CS_DISMISS)) { htmltext = "chamberlain-21.html"; } else if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else { htmltext = "chamberlain-10.html"; } break; } case "banish_foreigner": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_DISMISS)) { if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else { castle.banishForeigners(); htmltext = "chamberlain-11.html"; } } else { htmltext = "chamberlain-21.html"; } break; } case "doors": { if (!isOwner(player, npc) || !player.hasClanPrivilege(ClanPrivilege.CS_OPEN_DOOR)) { htmltext = "chamberlain-21.html"; } else if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else { htmltext = npc.getId() + "-d.html"; } break; } case "operate_door": { if (!isOwner(player, npc) || !player.hasClanPrivilege(ClanPrivilege.CS_OPEN_DOOR)) { htmltext = "chamberlain-21.html"; } else if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else { final boolean open = (Integer.parseInt(st.nextToken()) == 1); while (st.hasMoreTokens()) { castle.openCloseDoor(player, Integer.parseInt(st.nextToken()), open); } htmltext = (open ? "chamberlain-05.html" : "chamberlain-06.html"); } break; } case "additional_functions": { htmltext = (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) ? "castletdecomanage.html" : "chamberlain-21.html"; break; } case "recovery": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) { final NpcHtmlMessage html = getHtmlPacket(player, npc, "castledeco-AR01.html"); funcReplace(castle, html, Castle.FUNC_RESTORE_HP, "HP"); funcReplace(castle, html, Castle.FUNC_RESTORE_MP, "MP"); funcReplace(castle, html, Castle.FUNC_RESTORE_EXP, "XP"); player.sendPacket(html); } else { htmltext = "chamberlain-21.html"; } break; } case "other": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) { final NpcHtmlMessage html = getHtmlPacket(player, npc, "castledeco-AE01.html"); funcReplace(castle, html, Castle.FUNC_TELEPORT, "TP"); funcReplace(castle, html, Castle.FUNC_SUPPORT, "BF"); player.sendPacket(html); } else { htmltext = "chamberlain-21.html"; } break; } case "HP": { final int level = Integer.parseInt(st.nextToken()); htmltext = funcConfirmHtml(player, npc, castle, Castle.FUNC_RESTORE_HP, level); break; } case "MP": { final int level = Integer.parseInt(st.nextToken()); htmltext = funcConfirmHtml(player, npc, castle, Castle.FUNC_RESTORE_MP, level); break; } case "XP": { final int level = Integer.parseInt(st.nextToken()); htmltext = funcConfirmHtml(player, npc, castle, Castle.FUNC_RESTORE_EXP, level); break; } case "TP": { final int level = Integer.parseInt(st.nextToken()); htmltext = funcConfirmHtml(player, npc, castle, Castle.FUNC_TELEPORT, level); break; } case "BF": { final int level = Integer.parseInt(st.nextToken()); htmltext = funcConfirmHtml(player, npc, castle, Castle.FUNC_SUPPORT, level); break; } case "set_func": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) { final int func = Integer.parseInt(st.nextToken()); final int level = Integer.parseInt(st.nextToken()); if (level == 0) { castle.updateFunctions(player, func, level, 0, 0, false); } else if (!castle.updateFunctions( player, func, level, getFunctionFee(func, level), getFunctionRatio(func), castle.getFunction(func) == null)) { htmltext = "chamberlain-09.html"; } } else { htmltext = "chamberlain-21.html"; } break; } case "functions": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_USE_FUNCTIONS)) { final CastleFunction HP = castle.getFunction(Castle.FUNC_RESTORE_HP); final CastleFunction MP = castle.getFunction(Castle.FUNC_RESTORE_MP); final CastleFunction XP = castle.getFunction(Castle.FUNC_RESTORE_EXP); final NpcHtmlMessage html = getHtmlPacket(player, npc, "castledecofunction.html"); html.replace("%HPDepth%", (HP == null) ? "0" : Integer.toString(HP.getLvl())); html.replace("%MPDepth%", (MP == null) ? "0" : Integer.toString(MP.getLvl())); html.replace("%XPDepth%", (XP == null) ? "0" : Integer.toString(XP.getLvl())); player.sendPacket(html); } else { htmltext = "chamberlain-21.html"; } break; } case "teleport": { if (!isOwner(player, npc) || !player.hasClanPrivilege(ClanPrivilege.CS_USE_FUNCTIONS)) { htmltext = "chamberlain-21.html"; } else if (castle.getFunction(Castle.FUNC_TELEPORT) == null) { htmltext = "castlefuncdisabled.html"; } else { htmltext = npc.getId() + "-t" + castle.getFunction(Castle.FUNC_TELEPORT).getLvl() + ".html"; } break; } case "goto": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_USE_FUNCTIONS)) { final int locId = Integer.parseInt(st.nextToken()); final L2TeleportLocation list = TeleportLocationTable.getInstance().getTemplate(locId); if (list != null) { if (takeItems(player, list.getItemId(), list.getPrice())) { player.teleToLocation(list.getLocX(), list.getLocY(), list.getLocZ()); } } } else { htmltext = "chamberlain-21.html"; } break; } case "buffer": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_USE_FUNCTIONS)) { if (castle.getFunction(Castle.FUNC_SUPPORT) == null) { htmltext = "castlefuncdisabled.html"; } else { final NpcHtmlMessage html = getHtmlPacket( player, npc, "castlebuff-0" + castle.getFunction(Castle.FUNC_SUPPORT).getLvl() + ".html"); html.replace("%MPLeft%", Integer.toString((int) npc.getCurrentMp())); player.sendPacket(html); } } else { htmltext = "chamberlain-21.html"; } break; } case "cast_buff": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_USE_FUNCTIONS)) { if (castle.getFunction(Castle.FUNC_SUPPORT) == null) { htmltext = "castlefuncdisabled.html"; } else { final int index = Integer.parseInt(st.nextToken()); if (BUFFS.length > index) { final NpcHtmlMessage html; final SkillHolder holder = BUFFS[index]; if (holder.getSkill().getMpConsume() < npc.getCurrentMp()) { npc.setTarget(player); npc.doCast(holder.getSkill()); html = getHtmlPacket(player, npc, "castleafterbuff.html"); } else { html = getHtmlPacket(player, npc, "castlenotenoughmp.html"); } html.replace("%MPLeft%", Integer.toString((int) npc.getCurrentMp())); player.sendPacket(html); } } } else { htmltext = "chamberlain-21.html"; } break; } case "list_siege_clans": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_MANAGE_SIEGE)) { castle.getSiege().listRegisterClan(player); } else { htmltext = "chamberlain-21.html"; } break; } case "list_territory_clans": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_MANAGE_SIEGE)) { player.sendPacket(new ExShowDominionRegistry(castle.getResidenceId(), player)); } else { htmltext = "chamberlain-21.html"; } break; } case "manor": { if (Config.ALLOW_MANOR) { htmltext = (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_MANOR_ADMIN)) ? "manor.html" : "chamberlain-21.html"; } else { player.sendMessage("Manor system is deactivated."); } break; } case "products": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_USE_FUNCTIONS)) { final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-22.html"); html.replace("%npcId%", Integer.toString(npc.getId())); player.sendPacket(html); } else { htmltext = "chamberlain-21.html"; } break; } case "buy": { if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_USE_FUNCTIONS)) { ((L2MerchantInstance) npc).showBuyWindow(player, Integer.parseInt(st.nextToken())); } else { htmltext = "chamberlain-21.html"; } break; } case "give_crown": { if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else if (npc.isMyLord(player)) { if (hasQuestItems(player, CROWN)) { htmltext = "chamberlain-24.html"; } else { final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-25.html"); html.replace("%owner_name%", String.valueOf(player.getName())); html.replace( "%feud_name%", String.valueOf(String.valueOf(1001000 + castle.getResidenceId()))); player.sendPacket(html); giveItems(player, CROWN, 1); } } else { htmltext = "chamberlain-21.html"; } break; } case "manors_cert": { if (npc.isMyLord(player)) { if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else { if ((SevenSigns.getInstance().getPlayerCabal(player.getObjectId()) == SevenSigns.CABAL_DAWN) && SevenSigns.getInstance().isCompetitionPeriod()) { final int ticketCount = castle.getTicketBuyCount(); if (ticketCount < (Config.SSQ_DAWN_TICKET_QUANTITY / Config.SSQ_DAWN_TICKET_BUNDLE)) { final NpcHtmlMessage html = getHtmlPacket(player, npc, "ssq_selldawnticket.html"); html.replace( "%DawnTicketLeft%", String.valueOf( Config.SSQ_DAWN_TICKET_QUANTITY - (ticketCount * Config.SSQ_DAWN_TICKET_BUNDLE))); html.replace("%DawnTicketBundle%", String.valueOf(Config.SSQ_DAWN_TICKET_BUNDLE)); html.replace( "%DawnTicketPrice%", String.valueOf(Config.SSQ_DAWN_TICKET_PRICE * Config.SSQ_DAWN_TICKET_BUNDLE)); player.sendPacket(html); } else { htmltext = "ssq_notenoughticket.html"; } } else { htmltext = "ssq_notdawnorevent.html"; } } } else { htmltext = "chamberlain-21.html"; } break; } case "manors_cert_confirm": { if (npc.isMyLord(player)) { if (castle.getSiege().isInProgress()) { htmltext = "chamberlain-08.html"; } else { if ((SevenSigns.getInstance().getPlayerCabal(player.getObjectId()) == SevenSigns.CABAL_DAWN) && SevenSigns.getInstance().isCompetitionPeriod()) { final int ticketCount = castle.getTicketBuyCount(); if (ticketCount < (Config.SSQ_DAWN_TICKET_QUANTITY / Config.SSQ_DAWN_TICKET_BUNDLE)) { final long totalCost = Config.SSQ_DAWN_TICKET_PRICE * Config.SSQ_DAWN_TICKET_BUNDLE; if (player.getAdena() >= totalCost) { takeItems(player, Inventory.ADENA_ID, totalCost); giveItems( player, Config.SSQ_MANORS_AGREEMENT_ID, Config.SSQ_DAWN_TICKET_BUNDLE); castle.setTicketBuyCount(ticketCount + 1); } else { htmltext = "chamberlain-09.html"; } } else { htmltext = "ssq_notenoughticket.html"; } } else { htmltext = "ssq_notdawnorevent.html"; } } } else { htmltext = "chamberlain-21.html"; } break; } } return htmltext; }
private static final void showHtmlMenu(L2PcInstance player, int objectId, int level) { NpcHtmlMessage html = new NpcHtmlMessage(objectId); if (!Config.ALLOW_CLASS_MASTERS) { html.setFile(player.getHtmlPrefix(), "data/html/classmaster/disabled.htm"); } else if (!Config.CLASS_MASTER_SETTINGS.isAllowed(level)) { int jobLevel = player.getClassId().level(); final StringBuilder sb = new StringBuilder(100); sb.append("<html><body>"); switch (jobLevel) { case 0: if (Config.CLASS_MASTER_SETTINGS.isAllowed(1)) sb.append("Come back here when you reached level 20 to change your class.<br>"); else if (Config.CLASS_MASTER_SETTINGS.isAllowed(2)) sb.append("Come back after your first occupation change.<br>"); else if (Config.CLASS_MASTER_SETTINGS.isAllowed(3)) sb.append("Come back after your second occupation change.<br>"); else sb.append("I can't change your occupation.<br>"); break; case 1: if (Config.CLASS_MASTER_SETTINGS.isAllowed(2)) sb.append("Come back here when you reached level 40 to change your class.<br>"); else if (Config.CLASS_MASTER_SETTINGS.isAllowed(3)) sb.append("Come back after your second occupation change.<br>"); else sb.append("I can't change your occupation.<br>"); break; case 2: if (Config.CLASS_MASTER_SETTINGS.isAllowed(3)) sb.append("Come back here when you reached level 76 to change your class.<br>"); else sb.append("I can't change your occupation.<br>"); break; case 3: sb.append("There is no class change available for you anymore.<br>"); break; } sb.append("</body></html>"); html.setHtml(sb.toString()); } else { final ClassId currentClassId = player.getClassId(); if (currentClassId.level() >= level) { html.setFile(player.getHtmlPrefix(), "data/html/classmaster/nomore.htm"); } else { final int minLevel = getMinLevel(currentClassId.level()); if (player.getLevel() >= minLevel || Config.ALLOW_ENTIRE_TREE) { final StringBuilder menu = new StringBuilder(100); for (ClassId cid : ClassId.values()) { if (cid == ClassId.inspector && player.getTotalSubClasses() < 2) continue; if (validateClassId(currentClassId, cid) && cid.level() == level) { StringUtil.append( menu, "<a action=\"bypass -h npc_%objectId%_change_class ", String.valueOf(cid.getId()), "\">", CharTemplateTable.getInstance().getClassNameById(cid.getId()), "</a><br>"); } } if (menu.length() > 0) { html.setFile(player.getHtmlPrefix(), "data/html/classmaster/template.htm"); html.replace( "%name%", CharTemplateTable.getInstance().getClassNameById(currentClassId.getId())); html.replace("%menu%", menu.toString()); } else { html.setFile(player.getHtmlPrefix(), "data/html/classmaster/comebacklater.htm"); html.replace("%level%", String.valueOf(getMinLevel(level - 1))); } } else { if (minLevel < Integer.MAX_VALUE) { html.setFile(player.getHtmlPrefix(), "data/html/classmaster/comebacklater.htm"); html.replace("%level%", String.valueOf(minLevel)); } else html.setFile(player.getHtmlPrefix(), "data/html/classmaster/nomore.htm"); } } } html.replace("%objectId%", String.valueOf(objectId)); html.replace("%req_items%", getRequiredItems(level)); player.sendPacket(html); }
public void showHeroFights(L2PcInstance activeChar, int heroclass, int charid, int page) { final int perpage = 20; int _win = 0; int _loss = 0; int _draw = 0; if (_herofights.containsKey(charid)) { List<StatsSet> _list = _herofights.get(charid); final NpcHtmlMessage FightReply = new NpcHtmlMessage(); final String htmContent = HtmCache.getInstance() .getHtm(activeChar.getHtmlPrefix(), "data/html/olympiad/herohistory.htm"); if (htmContent != null) { FightReply.setHtml(htmContent); FightReply.replace("%heroname%", CharNameTable.getInstance().getNameById(charid)); if (!_list.isEmpty()) { if (_herocounts.containsKey(charid)) { StatsSet _herocount = _herocounts.get(charid); _win = _herocount.getInt("victory"); _loss = _herocount.getInt("loss"); _draw = _herocount.getInt("draw"); } boolean color = true; final StringBuilder fList = new StringBuilder(500); int counter = 0; int breakat = 0; for (int i = ((page - 1) * perpage); i < _list.size(); i++) { breakat = i; StatsSet fight = _list.get(i); StringUtil.append(fList, "<tr><td>"); if (color) { StringUtil.append(fList, "<table width=270 bgcolor=\"131210\">"); } else { StringUtil.append(fList, "<table width=270>"); } StringUtil.append( fList, "<tr><td width=220><font color=\"LEVEL\">" + fight.getString("start") + "</font> " + fight.getString("result") + "</td><td width=50 align=right>" + (fight.getInt("classed") > 0 ? "<font color=\"FFFF99\">cls</font>" : "<font color=\"999999\">non-cls<font>") + "</td></tr>"); StringUtil.append( fList, "<tr><td width=220>vs " + fight.getString("oponent") + " (" + fight.getString("oponentclass") + ")</td><td width=50 align=right>(" + fight.getString("time") + ")</td></tr>"); StringUtil.append(fList, "<tr><td colspan=2> </td></tr></table>"); StringUtil.append(fList, "</td></tr>"); color = !color; counter++; if (counter >= perpage) { break; } } if (breakat < (_list.size() - 1)) { FightReply.replace( "%buttprev%", "<button value=\"Prev\" action=\"bypass _match?class=" + heroclass + "&page=" + (page + 1) + "\" width=60 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"); } else { FightReply.replace("%buttprev%", ""); } if (page > 1) { FightReply.replace( "%buttnext%", "<button value=\"Next\" action=\"bypass _match?class=" + heroclass + "&page=" + (page - 1) + "\" width=60 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"); } else { FightReply.replace("%buttnext%", ""); } FightReply.replace("%list%", fList.toString()); } else { FightReply.replace("%list%", ""); FightReply.replace("%buttprev%", ""); FightReply.replace("%buttnext%", ""); } FightReply.replace("%win%", String.valueOf(_win)); FightReply.replace("%draw%", String.valueOf(_draw)); FightReply.replace("%loos%", String.valueOf(_loss)); activeChar.sendPacket(FightReply); } } }
public void showHeroDiary(L2PcInstance activeChar, int heroclass, int charid, int page) { final int perpage = 10; if (_herodiary.containsKey(charid)) { List<StatsSet> _mainlist = _herodiary.get(charid); final NpcHtmlMessage DiaryReply = new NpcHtmlMessage(); final String htmContent = HtmCache.getInstance() .getHtm(activeChar.getHtmlPrefix(), "data/html/olympiad/herodiary.htm"); if ((htmContent != null) && _heroMessage.containsKey(charid)) { DiaryReply.setHtml(htmContent); DiaryReply.replace("%heroname%", CharNameTable.getInstance().getNameById(charid)); DiaryReply.replace("%message%", _heroMessage.get(charid)); DiaryReply.disableValidation(); if (!_mainlist.isEmpty()) { FastList<StatsSet> _list = FastList.newInstance(); _list.addAll(_mainlist); Collections.reverse(_list); boolean color = true; final StringBuilder fList = new StringBuilder(500); int counter = 0; int breakat = 0; for (int i = ((page - 1) * perpage); i < _list.size(); i++) { breakat = i; StatsSet _diaryentry = _list.get(i); StringUtil.append(fList, "<tr><td>"); if (color) { StringUtil.append(fList, "<table width=270 bgcolor=\"131210\">"); } else { StringUtil.append(fList, "<table width=270>"); } StringUtil.append( fList, "<tr><td width=270><font color=\"LEVEL\">" + _diaryentry.getString("date") + ":xx</font></td></tr>"); StringUtil.append( fList, "<tr><td width=270>" + _diaryentry.getString("action") + "</td></tr>"); StringUtil.append(fList, "<tr><td> </td></tr></table>"); StringUtil.append(fList, "</td></tr>"); color = !color; counter++; if (counter >= perpage) { break; } } if (breakat < (_list.size() - 1)) { DiaryReply.replace( "%buttprev%", "<button value=\"Prev\" action=\"bypass _diary?class=" + heroclass + "&page=" + (page + 1) + "\" width=60 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"); } else { DiaryReply.replace("%buttprev%", ""); } if (page > 1) { DiaryReply.replace( "%buttnext%", "<button value=\"Next\" action=\"bypass _diary?class=" + heroclass + "&page=" + (page - 1) + "\" width=60 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"); } else { DiaryReply.replace("%buttnext%", ""); } DiaryReply.replace("%list%", fList.toString()); FastList.recycle(_list); } else { DiaryReply.replace("%list%", ""); DiaryReply.replace("%buttprev%", ""); DiaryReply.replace("%buttnext%", ""); } activeChar.sendPacket(DiaryReply); } } }
@Override public void onBypassFeedback(L2PcInstance player, String command) { String[] commandStr = command.split(" "); String actualCommand = commandStr[0]; // Get actual command String cmdParams = ""; String cmdParams2 = ""; if (commandStr.length >= 2) cmdParams = commandStr[1]; if (commandStr.length >= 3) cmdParams2 = commandStr[2]; if (actualCommand.equalsIgnoreCase("create_clan")) { if (cmdParams.isEmpty()) return; ClanTable.getInstance().createClan(player, cmdParams); } else if (actualCommand.equalsIgnoreCase("create_academy")) { if (cmdParams.isEmpty()) return; createSubPledge(player, cmdParams, null, L2Clan.SUBUNIT_ACADEMY, 5); } else if (actualCommand.equalsIgnoreCase("rename_pledge")) { if (cmdParams.isEmpty() || cmdParams2.isEmpty()) return; renameSubPledge(player, Integer.valueOf(cmdParams), cmdParams2); } else if (actualCommand.equalsIgnoreCase("create_royal")) { if (cmdParams.isEmpty()) return; createSubPledge(player, cmdParams, cmdParams2, L2Clan.SUBUNIT_ROYAL1, 6); } else if (actualCommand.equalsIgnoreCase("create_knight")) { if (cmdParams.isEmpty()) return; createSubPledge(player, cmdParams, cmdParams2, L2Clan.SUBUNIT_KNIGHT1, 7); } else if (actualCommand.equalsIgnoreCase("assign_subpl_leader")) { if (cmdParams.isEmpty()) return; assignSubPledgeLeader(player, cmdParams, cmdParams2); } else if (actualCommand.equalsIgnoreCase("create_ally")) { if (cmdParams.isEmpty()) return; if (player.getClan() == null) player.sendPacket(new SystemMessage(SystemMessageId.ONLY_CLAN_LEADER_CREATE_ALLIANCE)); else player.getClan().createAlly(player, cmdParams); } else if (actualCommand.equalsIgnoreCase("dissolve_ally")) { player.getClan().dissolveAlly(player); } else if (actualCommand.equalsIgnoreCase("dissolve_clan")) { dissolveClan(player, player.getClanId()); } else if (actualCommand.equalsIgnoreCase("change_clan_leader")) { if (cmdParams.isEmpty()) return; changeClanLeader(player, cmdParams); } else if (actualCommand.equalsIgnoreCase("recover_clan")) { recoverClan(player, player.getClanId()); } else if (actualCommand.equalsIgnoreCase("increase_clan_level")) { if (player.getClan().levelUpClan(player)) { player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 0, 0)); player.broadcastPacket(new MagicSkillLaunched(player, 5103, 1)); } } else if (actualCommand.equalsIgnoreCase("learn_clan_skills")) { showPledgeSkillList(player); } else if (command.startsWith("Subclass")) { // Subclasses may not be changed while a skill is in use. if (player.isCastingNow() || player.isAllSkillsDisabled()) { player.sendPacket( new SystemMessage(SystemMessageId.SUBCLASS_NO_CHANGE_OR_CREATE_WHILE_SKILL_IN_USE)); return; } NpcHtmlMessage html = new NpcHtmlMessage(getObjectId()); if (player.getTransformation() != null) { html.setFile(player.getHtmlPrefix(), "data/html/villagemaster/SubClass_NoTransformed.htm"); player.sendPacket(html); return; } int cmdChoice = 0; int paramOne = 0; int paramTwo = 0; try { cmdChoice = Integer.parseInt(command.substring(9, 10).trim()); int endIndex = command.indexOf(' ', 11); if (endIndex == -1) endIndex = command.length(); paramOne = Integer.parseInt(command.substring(11, endIndex).trim()); if (command.length() > endIndex) paramTwo = Integer.parseInt(command.substring(endIndex).trim()); } catch (Exception NumberFormatException) { } switch (cmdChoice) { case 0: // Subclass change menu html.setFile(player.getHtmlPrefix(), getSubClassMenu(player.getRace())); break; case 1: // Add Subclass - Initial // Avoid giving player an option to add a new sub class, if they have three already. if (player.getTotalSubClasses() >= Config.MAX_SUBCLASS) { html.setFile(player.getHtmlPrefix(), getSubClassFail()); break; } html.setFile(player.getHtmlPrefix(), "data/html/villagemaster/SubClass_Add.htm"); final StringBuilder content1 = StringUtil.startAppend(200); Set<PlayerClass> subsAvailable = getAvailableSubClasses(player); if (subsAvailable != null && !subsAvailable.isEmpty()) { for (PlayerClass subClass : subsAvailable) { StringUtil.append( content1, "<a action=\"bypass -h npc_%objectId%_Subclass 4 ", String.valueOf(subClass.ordinal()), "\" msg=\"1268;", formatClassForDisplay(subClass), "\">", formatClassForDisplay(subClass), "</a><br>"); } } else { // TODO: Retail message player.sendMessage("There are no sub classes available at this time."); return; } html.replace("%list%", content1.toString()); break; case 2: // Change Class - Initial if (player.getSubClasses().isEmpty()) html.setFile(player.getHtmlPrefix(), "data/html/villagemaster/SubClass_ChangeNo.htm"); else { final StringBuilder content2 = StringUtil.startAppend(200); if (checkVillageMaster(player.getBaseClass())) { StringUtil.append( content2, "<a action=\"bypass -h npc_%objectId%_Subclass 5 0\">", CharTemplateTable.getInstance().getClassNameById(player.getBaseClass()), "</a><br>"); } for (Iterator<SubClass> subList = iterSubClasses(player); subList.hasNext(); ) { SubClass subClass = subList.next(); if (checkVillageMaster(subClass.getClassDefinition())) { StringUtil.append( content2, "<a action=\"bypass -h npc_%objectId%_Subclass 5 ", String.valueOf(subClass.getClassIndex()), "\">", formatClassForDisplay(subClass.getClassDefinition()), "</a><br>"); } } if (content2.length() > 0) { html.setFile(player.getHtmlPrefix(), "data/html/villagemaster/SubClass_Change.htm"); html.replace("%list%", content2.toString()); } else html.setFile( player.getHtmlPrefix(), "data/html/villagemaster/SubClass_ChangeNotFound.htm"); } break; case 3: // Change/Cancel Subclass - Initial if (player.getSubClasses() == null || player.getSubClasses().isEmpty()) { html.setFile( player.getHtmlPrefix(), "data/html/villagemaster/SubClass_ModifyEmpty.htm"); break; } // custom value if (player.getTotalSubClasses() > 3) { html.setFile( player.getHtmlPrefix(), "data/html/villagemaster/SubClass_ModifyCustom.htm"); final StringBuilder content3 = StringUtil.startAppend(200); int classIndex = 1; for (Iterator<SubClass> subList = iterSubClasses(player); subList.hasNext(); ) { SubClass subClass = subList.next(); StringUtil.append( content3, "Sub-class ", String.valueOf(classIndex++), "<br>", "<a action=\"bypass -h npc_%objectId%_Subclass 6 ", String.valueOf(subClass.getClassIndex()), "\">", CharTemplateTable.getInstance().getClassNameById(subClass.getClassId()), "</a><br>"); } html.replace("%list%", content3.toString()); } else { // retail html contain only 3 subclasses html.setFile(player.getHtmlPrefix(), "data/html/villagemaster/SubClass_Modify.htm"); if (player.getSubClasses().containsKey(1)) html.replace( "%sub1%", CharTemplateTable.getInstance() .getClassNameById(player.getSubClasses().get(1).getClassId())); else html.replace( "<a action=\"bypass -h npc_%objectId%_Subclass 6 1\">%sub1%</a><br>", ""); if (player.getSubClasses().containsKey(2)) html.replace( "%sub2%", CharTemplateTable.getInstance() .getClassNameById(player.getSubClasses().get(2).getClassId())); else html.replace( "<a action=\"bypass -h npc_%objectId%_Subclass 6 2\">%sub2%</a><br>", ""); if (player.getSubClasses().containsKey(3)) html.replace( "%sub3%", CharTemplateTable.getInstance() .getClassNameById(player.getSubClasses().get(3).getClassId())); else html.replace( "<a action=\"bypass -h npc_%objectId%_Subclass 6 3\">%sub3%</a><br>", ""); } break; case 4: // Add Subclass - Action (Subclass 4 x[x]) /* * If the character is less than level 75 on any of their previously chosen * classes then disallow them to change to their most recently added sub-class choice. */ if (!player.getFloodProtectors().getSubclass().tryPerformAction("add subclass")) { _log.warning( "Player " + player.getName() + " has performed a subclass change too fast"); return; } boolean allowAddition = true; if (player.getTotalSubClasses() >= Config.MAX_SUBCLASS) allowAddition = false; if (player.getLevel() < 75) allowAddition = false; if (allowAddition) { if (!player.getSubClasses().isEmpty()) { for (Iterator<SubClass> subList = iterSubClasses(player); subList.hasNext(); ) { SubClass subClass = subList.next(); if (subClass.getLevel() < 75) { allowAddition = false; break; } } } } /* * If quest checking is enabled, verify if the character has completed the Mimir's Elixir (Path to Subclass) * and Fate's Whisper (A Grade Weapon) quests by checking for instances of their unique reward items. * * If they both exist, remove both unique items and continue with adding the sub-class. */ if (allowAddition && !Config.ALT_GAME_SUBCLASS_WITHOUT_QUESTS) allowAddition = checkQuests(player); if (allowAddition && isValidNewSubClass(player, paramOne)) { if (!player.addSubClass(paramOne, player.getTotalSubClasses() + 1)) return; player.setActiveClass(player.getTotalSubClasses()); html.setFile(player.getHtmlPrefix(), "data/html/villagemaster/SubClass_AddOk.htm"); player.sendPacket( new SystemMessage(SystemMessageId.ADD_NEW_SUBCLASS)); // Subclass added. } else html.setFile(player.getHtmlPrefix(), getSubClassFail()); break; case 5: // Change Class - Action /* * If the character is less than level 75 on any of their previously chosen * classes then disallow them to change to their most recently added sub-class choice. * * Note: paramOne = classIndex */ if (!player.getFloodProtectors().getSubclass().tryPerformAction("change class")) { _log.warning( "Player " + player.getName() + " has performed a subclass change too fast"); return; } if (player.getClassIndex() == paramOne) { html.setFile(player.getHtmlPrefix(), "data/html/villagemaster/SubClass_Current.htm"); break; } if (paramOne == 0) { if (!checkVillageMaster(player.getBaseClass())) return; } else { try { if (!checkVillageMaster(player.getSubClasses().get(paramOne).getClassDefinition())) return; } catch (NullPointerException e) { return; } } player.setActiveClass(paramOne); player.sendPacket( new SystemMessage( SystemMessageId.SUBCLASS_TRANSFER_COMPLETED)); // Transfer completed. return; case 6: // Change/Cancel Subclass - Choice // validity check if (paramOne < 1 || paramOne > Config.MAX_SUBCLASS) return; subsAvailable = getAvailableSubClasses(player); // another validity check if (subsAvailable == null || subsAvailable.isEmpty()) { // TODO: Retail message player.sendMessage("There are no sub classes available at this time."); return; } final StringBuilder content6 = StringUtil.startAppend(200); for (PlayerClass subClass : subsAvailable) { StringUtil.append( content6, "<a action=\"bypass -h npc_%objectId%_Subclass 7 ", String.valueOf(paramOne), " ", String.valueOf(subClass.ordinal()), "\" msg=\"1445;", "\">", formatClassForDisplay(subClass), "</a><br>"); } switch (paramOne) { case 1: html.setFile( player.getHtmlPrefix(), "data/html/villagemaster/SubClass_ModifyChoice1.htm"); break; case 2: html.setFile( player.getHtmlPrefix(), "data/html/villagemaster/SubClass_ModifyChoice2.htm"); break; case 3: html.setFile( player.getHtmlPrefix(), "data/html/villagemaster/SubClass_ModifyChoice3.htm"); break; default: html.setFile( player.getHtmlPrefix(), "data/html/villagemaster/SubClass_ModifyChoice.htm"); } html.replace("%list%", content6.toString()); break; case 7: // Change Subclass - Action /* * Warning: the information about this subclass will be removed from the * subclass list even if false! */ if (!player.getFloodProtectors().getSubclass().tryPerformAction("change class")) { _log.warning( "Player " + player.getName() + " has performed a subclass change too fast"); return; } if (!isValidNewSubClass(player, paramTwo)) return; if (player.modifySubClass(paramOne, paramTwo)) { player.abortCast(); player .stopAllEffectsExceptThoseThatLastThroughDeath(); // all effects from old subclass // stopped! player.stopCubics(); player.setActiveClass(paramOne); html.setFile(player.getHtmlPrefix(), "data/html/villagemaster/SubClass_ModifyOk.htm"); html.replace("%name%", CharTemplateTable.getInstance().getClassNameById(paramTwo)); player.sendPacket( new SystemMessage(SystemMessageId.ADD_NEW_SUBCLASS)); // Subclass added. } else { /* * This isn't good! modifySubClass() removed subclass from memory * we must update _classIndex! Else IndexOutOfBoundsException can turn * up some place down the line along with other seemingly unrelated * problems. */ player.setActiveClass( 0); // Also updates _classIndex plus switching _classid to baseclass. player.sendMessage( "The sub class could not be added, you have been reverted to your base class."); return; } break; } html.replace("%objectId%", String.valueOf(getObjectId())); player.sendPacket(html); } else { // this class dont know any other commands, let forward // the command to the parent class super.onBypassFeedback(player, command); } }
public void showHtmlFile(L2PcInstance player, String file, L2Npc npc) { NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId()); html.setFile(player.getHtmlPrefix(), file); html.replace("%npc_name%", npc.getName()); player.sendPacket(html); }
public synchronized void start(L2PcInstance player, byte type, L2Npc npc) { boolean canPass = true; if (!player.isInParty()) { showHtmlFile(player, "data/html/seven_signs/rift/NoParty.htm", npc); return; } if (player.getParty().getPartyLeaderOID() != player.getObjectId()) { showHtmlFile(player, "data/html/seven_signs/rift/NotPartyLeader.htm", npc); return; } if (player.getParty().isInDimensionalRift()) { handleCheat(player, npc); return; } if (player.getParty().getMemberCount() < Config.RIFT_MIN_PARTY_SIZE) { NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId()); html.setFile(player.getHtmlPrefix(), "data/html/seven_signs/rift/SmallParty.htm"); html.replace("%npc_name%", npc.getName()); html.replace("%count%", Integer.toString(Config.RIFT_MIN_PARTY_SIZE)); player.sendPacket(html); return; } // max parties inside is rooms count - 1 if (!isAllowedEnter(type)) { player.sendMessage("Rift is full. Try later."); return; } for (L2PcInstance p : player.getParty().getPartyMembers()) if (!checkIfInPeaceZone(p.getX(), p.getY(), p.getZ())) { canPass = false; break; } if (!canPass) { showHtmlFile(player, "data/html/seven_signs/rift/NotInWaitingRoom.htm", npc); return; } L2ItemInstance i; int count = getNeededItems(type); for (L2PcInstance p : player.getParty().getPartyMembers()) { i = p.getInventory().getItemByItemId(DIMENSIONAL_FRAGMENT_ITEM_ID); if (i == null) { canPass = false; break; } if (i.getCount() > 0) { if (i.getCount() < getNeededItems(type)) { canPass = false; break; } } else { canPass = false; break; } } if (!canPass) { NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId()); html.setFile(player.getHtmlPrefix(), "data/html/seven_signs/rift/NoFragments.htm"); html.replace("%npc_name%", npc.getName()); html.replace("%count%", Integer.toString(count)); player.sendPacket(html); return; } for (L2PcInstance p : player.getParty().getPartyMembers()) { i = p.getInventory().getItemByItemId(DIMENSIONAL_FRAGMENT_ITEM_ID); if (!p.destroyItem("RiftEntrance", i, count, null, false)) { NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId()); html.setFile(player.getHtmlPrefix(), "data/html/seven_signs/rift/NoFragments.htm"); html.replace("%npc_name%", npc.getName()); html.replace("%count%", Integer.toString(count)); player.sendPacket(html); return; } } byte room; FastList<Byte> emptyRooms; do { emptyRooms = getFreeRooms(type); room = emptyRooms.get(Rnd.get(1, emptyRooms.size()) - 1); } // find empty room while (_rooms.get(type).get(room).ispartyInside()); new DimensionalRift(player.getParty(), type, room); }