private final int getTrapUpgradePrice(final int level) { int price = 0; switch (level) { case 1: price = Config.TRAP_UPGRADE_PRICE1; break; case 2: price = Config.TRAP_UPGRADE_PRICE2; break; case 3: price = Config.TRAP_UPGRADE_PRICE3; break; case 4: price = Config.TRAP_UPGRADE_PRICE4; break; } switch (SevenSigns.getInstance().getSealOwner(SevenSigns.SEAL_STRIFE)) { case SevenSigns.CABAL_DUSK: price *= 3; break; case SevenSigns.CABAL_DAWN: price *= 0.8; break; } return price; }
@Override protected void runImpl() { L2PcInstance activeChar = getClient().getActiveChar(); if (activeChar == null) { return; } if ((SevenSigns.getInstance().isSealValidationPeriod() || SevenSigns.getInstance().isCompResultsPeriod()) && (_page == 4)) { return; } SSQStatus ssqs = new SSQStatus(activeChar.getObjectId(), _page); activeChar.sendPacket(ssqs); }
private final int getDoorUpgradePrice(final int type, final int level) { int price = 0; switch (type) { case 1: // Outer Door { switch (level) { case 2: price = Config.OUTER_DOOR_UPGRADE_PRICE2; break; case 3: price = Config.OUTER_DOOR_UPGRADE_PRICE3; break; case 5: price = Config.OUTER_DOOR_UPGRADE_PRICE5; break; } break; } case 2: // Inner Door { switch (level) { case 2: price = Config.INNER_DOOR_UPGRADE_PRICE2; break; case 3: price = Config.INNER_DOOR_UPGRADE_PRICE3; break; case 5: price = Config.INNER_DOOR_UPGRADE_PRICE5; break; } break; } case 3: // Wall { switch (level) { case 2: price = Config.WALL_UPGRADE_PRICE2; break; case 3: price = Config.WALL_UPGRADE_PRICE3; break; case 5: price = Config.WALL_UPGRADE_PRICE5; break; } break; } } switch (SevenSigns.getInstance().getSealOwner(SevenSigns.SEAL_STRIFE)) { case SevenSigns.CABAL_DUSK: price *= 3; break; case SevenSigns.CABAL_DAWN: price *= 0.8; break; } return price; }
private final int getTaxLimit() { final int taxLimit; switch (SevenSigns.getInstance().getSealOwner(SevenSigns.SEAL_STRIFE)) { case SevenSigns.CABAL_DAWN: taxLimit = 25; break; case SevenSigns.CABAL_DUSK: taxLimit = 5; break; default: taxLimit = 15; break; } return taxLimit; }
private final String getSealOwner(final int seal) { String npcString; switch (SevenSigns.getInstance().getSealOwner(seal)) { case SevenSigns.CABAL_DAWN: npcString = "1000511"; break; case SevenSigns.CABAL_DUSK: npcString = "1000510"; break; default: npcString = "1000512"; break; } return npcString; }
@Override public boolean testImpl(L2Character effector, L2Character effected, Skill skill, L2Item item) { if ((effector == null) || !effector.isPlayer()) { return !_val; } final L2PcInstance player = effector.getActingPlayer(); boolean canSummonSiegeGolem = true; if (player.isAlikeDead() || player.isCursedWeaponEquipped() || (player.getClan() == null)) { canSummonSiegeGolem = false; } final Castle castle = CastleManager.getInstance().getCastle(player); final Fort fort = FortManager.getInstance().getFort(player); if ((castle == null) && (fort == null)) { canSummonSiegeGolem = false; } if (((fort != null) && (fort.getResidenceId() == 0)) || ((castle != null) && (castle.getResidenceId() == 0))) { player.sendPacket(SystemMessageId.INCORRECT_TARGET); canSummonSiegeGolem = false; } else if (((castle != null) && !castle.getSiege().isInProgress()) || ((fort != null) && !fort.getSiege().isInProgress())) { player.sendPacket(SystemMessageId.INCORRECT_TARGET); canSummonSiegeGolem = false; } else if ((player.getClanId() != 0) && (((castle != null) && (castle.getSiege().getAttackerClan(player.getClanId()) == null)) || ((fort != null) && (fort.getSiege().getAttackerClan(player.getClanId()) == null)))) { player.sendPacket(SystemMessageId.INCORRECT_TARGET); canSummonSiegeGolem = false; } else if ((SevenSigns.getInstance().checkSummonConditions(player))) { canSummonSiegeGolem = false; } return (_val == canSummonSiegeGolem); }
/** * Admin Command Handler for Mammon NPCs * * @author Tempy, Zoey76 */ public class AdminMammon implements IAdminCommandHandler { private static final String[] ADMIN_COMMANDS = { "admin_mammon_find", "admin_mammon_respawn", }; private boolean _isSealValidation = SevenSigns.getInstance().isSealValidationPeriod(); @Override public boolean useAdminCommand(String command, L2PcInstance activeChar) { int teleportIndex = -1; final AutoSpawnInstance blackSpawnInst = AutoSpawnHandler.getInstance().getAutoSpawnInstance(SevenSigns.MAMMON_BLACKSMITH_ID, false); final AutoSpawnInstance merchSpawnInst = AutoSpawnHandler.getInstance().getAutoSpawnInstance(SevenSigns.MAMMON_MERCHANT_ID, false); if (command.startsWith("admin_mammon_find")) { try { if (command.length() > 17) { teleportIndex = Integer.parseInt(command.substring(18)); } } catch (Exception NumberFormatException) { activeChar.sendMessage( "Usage: //mammon_find [teleportIndex] (where 1 = Blacksmith, 2 = Merchant)"); return false; } if (!_isSealValidation) { activeChar.sendPacket(SystemMessageId.SSQ_COMPETITION_UNDERWAY); return false; } if (blackSpawnInst != null) { final L2Npc[] blackInst = blackSpawnInst.getNPCInstanceList(); if (blackInst.length > 0) { final int x1 = blackInst[0].getX(), y1 = blackInst[0].getY(), z1 = blackInst[0].getZ(); activeChar.sendMessage( MessageTable.Messages[1739].getMessage() + x1 + " " + y1 + " " + z1); if (teleportIndex == 1) { activeChar.teleToLocation(x1, y1, z1, true); } } } else { activeChar.sendMessage(1740); } if (merchSpawnInst != null) { final L2Npc[] merchInst = merchSpawnInst.getNPCInstanceList(); if (merchInst.length > 0) { final int x2 = merchInst[0].getX(), y2 = merchInst[0].getY(), z2 = merchInst[0].getZ(); activeChar.sendMessage( MessageTable.Messages[1741].getMessage() + x2 + " " + y2 + " " + z2); if (teleportIndex == 2) { activeChar.teleToLocation(x2, y2, z2, true); } } } else { activeChar.sendMessage(1742); } } else if (command.startsWith("admin_mammon_respawn")) { if (!_isSealValidation) { activeChar.sendPacket(SystemMessageId.SSQ_COMPETITION_UNDERWAY); return true; } if (merchSpawnInst != null) { long merchRespawn = AutoSpawnHandler.getInstance().getTimeToNextSpawn(merchSpawnInst); activeChar.sendMessage( MessageTable.Messages[1743].getExtra(1) + (merchRespawn / 60000) + MessageTable.Messages[1743].getExtra(2)); } else { activeChar.sendMessage(1742); } if (blackSpawnInst != null) { long blackRespawn = AutoSpawnHandler.getInstance().getTimeToNextSpawn(blackSpawnInst); activeChar.sendMessage( MessageTable.Messages[1744].getExtra(1) + (blackRespawn / 60000) + MessageTable.Messages[1744].getExtra(2)); } else { activeChar.sendMessage(1740); } } return true; } @Override public String[] getAdminCommandList() { return ADMIN_COMMANDS; } }
@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; }
/** * Admin Command Handler for Mammon NPCs * * @author Tempy */ public class AdminMammon implements IAdminCommandHandler { private static final String[] ADMIN_COMMANDS = { "admin_mammon_find", "admin_mammon_respawn", "admin_list_spawns", "admin_msg" }; private boolean _isSealValidation = SevenSigns.getInstance().isSealValidationPeriod(); public boolean useAdminCommand(String command, L2PcInstance activeChar) { int npcId = 0; int teleportIndex = -1; AutoSpawnInstance blackSpawnInst = AutoSpawnHandler.getInstance().getAutoSpawnInstance(SevenSigns.MAMMON_BLACKSMITH_ID, false); AutoSpawnInstance merchSpawnInst = AutoSpawnHandler.getInstance().getAutoSpawnInstance(SevenSigns.MAMMON_MERCHANT_ID, false); if (command.startsWith("admin_mammon_find")) { try { if (command.length() > 17) teleportIndex = Integer.parseInt(command.substring(18)); } catch (Exception NumberFormatException) { activeChar.sendMessage( "Usage: //mammon_find [teleportIndex] (where 1 = Blacksmith, 2 = Merchant)"); } if (!_isSealValidation) { activeChar.sendMessage(1738); return true; } if (blackSpawnInst != null) { L2Npc[] blackInst = blackSpawnInst.getNPCInstanceList(); if (blackInst.length > 0) { int x1 = blackInst[0].getX(), y1 = blackInst[0].getY(), z1 = blackInst[0].getZ(); activeChar.sendMessage( MessageTable.Messages[1739].getMessage() + x1 + " " + y1 + " " + z1); if (teleportIndex == 1) activeChar.teleToLocation(x1, y1, z1, true); } } else activeChar.sendMessage(1740); if (merchSpawnInst != null) { L2Npc[] merchInst = merchSpawnInst.getNPCInstanceList(); if (merchInst.length > 0) { int x2 = merchInst[0].getX(), y2 = merchInst[0].getY(), z2 = merchInst[0].getZ(); activeChar.sendMessage( MessageTable.Messages[1741].getMessage() + x2 + " " + y2 + " " + z2); if (teleportIndex == 2) activeChar.teleToLocation(x2, y2, z2, true); } } else activeChar.sendMessage(1742); } else if (command.startsWith("admin_mammon_respawn")) { if (!_isSealValidation) { activeChar.sendMessage(1738); return true; } if (merchSpawnInst != null) { long merchRespawn = AutoSpawnHandler.getInstance().getTimeToNextSpawn(merchSpawnInst); activeChar.sendMessage( MessageTable.Messages[1743].getExtra(1) + (merchRespawn / 60000) + MessageTable.Messages[1743].getExtra(2)); } else activeChar.sendMessage(1742); if (blackSpawnInst != null) { long blackRespawn = AutoSpawnHandler.getInstance().getTimeToNextSpawn(blackSpawnInst); activeChar.sendMessage( MessageTable.Messages[1744].getExtra(1) + (blackRespawn / 60000) + MessageTable.Messages[1744].getExtra(2)); } else activeChar.sendMessage(1740); } else if (command.startsWith("admin_list_spawns")) { try { // admin_list_spawns x[xxxx] x[xx] String[] params = command.split(" "); Pattern pattern = Pattern.compile("[0-9]*"); Matcher regexp = pattern.matcher(params[1]); if (regexp.matches()) npcId = Integer.parseInt(params[1]); else { params[1] = params[1].replace('_', ' '); npcId = NpcTable.getInstance().getTemplateByName(params[1]).npcId; } if (params.length > 2) teleportIndex = Integer.parseInt(params[2]); } catch (Exception e) { activeChar.sendMessage("Command format is //list_spawns <npcId|npc_name> [tele_index]"); } SpawnTable.getInstance().findNPCInstances(activeChar, npcId, teleportIndex); } // Used for testing SystemMessage IDs - Use //msg <ID> else if (command.startsWith("admin_msg")) { int msgId = -1; try { msgId = Integer.parseInt(command.substring(10).trim()); } catch (Exception e) { activeChar.sendMessage("Command format: //msg <SYSTEM_MSG_ID>"); return true; } activeChar.sendPacket(new SystemMessage(msgId)); } return true; } public String[] getAdminCommandList() { return ADMIN_COMMANDS; } }
@Override public boolean useAdminCommand(String command, L2PcInstance activeChar) { if (command.equals("admin_show_spawns")) { AdminHtml.showAdminHtml(activeChar, "spawns.htm"); } else if (command.equalsIgnoreCase("admin_spawn_debug_menu")) { AdminHtml.showAdminHtml(activeChar, "spawns_debug.htm"); } else if (command.startsWith("admin_spawn_debug_print")) { StringTokenizer st = new StringTokenizer(command, " "); L2Object target = activeChar.getTarget(); if (target instanceof L2Npc) { try { st.nextToken(); int type = Integer.parseInt(st.nextToken()); printSpawn((L2Npc) target, type); if (command.contains("_menu")) { AdminHtml.showAdminHtml(activeChar, "spawns_debug.htm"); } } catch (Exception e) { } } else { activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET); } } else if (command.startsWith("admin_spawn_index")) { StringTokenizer st = new StringTokenizer(command, " "); try { st.nextToken(); int level = Integer.parseInt(st.nextToken()); int from = 0; try { from = Integer.parseInt(st.nextToken()); } catch (NoSuchElementException nsee) { } showMonsters(activeChar, level, from); } catch (Exception e) { AdminHtml.showAdminHtml(activeChar, "spawns.htm"); } } else if (command.equals("admin_show_npcs")) { AdminHtml.showAdminHtml(activeChar, "npcs.htm"); } else if (command.startsWith("admin_npc_index")) { StringTokenizer st = new StringTokenizer(command, " "); try { st.nextToken(); String letter = st.nextToken(); int from = 0; try { from = Integer.parseInt(st.nextToken()); } catch (NoSuchElementException nsee) { } showNpcs(activeChar, letter, from); } catch (Exception e) { AdminHtml.showAdminHtml(activeChar, "npcs.htm"); } } else if (command.startsWith("admin_instance_spawns")) { StringTokenizer st = new StringTokenizer(command, " "); try { st.nextToken(); int instance = Integer.parseInt(st.nextToken()); if (instance >= 300000) { final StringBuilder html = StringUtil.startAppend( 500 + 1000, "<html><table width=\"100%\"><tr><td width=45><button value=\"Main\" action=\"bypass -h admin_admin\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=180><center>", "<font color=\"LEVEL\">Spawns for " + String.valueOf(instance) + "</font>", "</td><td width=45><button value=\"Back\" action=\"bypass -h admin_current_player\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table><br>", "<table width=\"100%\"><tr><td width=200>NpcName</td><td width=70>Action</td></tr>"); int counter = 0; int skiped = 0; Instance inst = InstanceManager.getInstance().getInstance(instance); if (inst != null) { for (L2Npc npc : inst.getNpcs()) { if (!npc.isDead()) { // Only 50 because of client html limitation if (counter < 50) { StringUtil.append( html, "<tr><td>" + npc.getName() + "</td><td>", "<a action=\"bypass -h admin_move_to " + npc.getX() + " " + npc.getY() + " " + npc.getZ() + "\">Go</a>", "</td></tr>"); counter++; } else { skiped++; } } } StringUtil.append( html, "<tr><td>Skipped:</td><td>" + String.valueOf(skiped) + "</td></tr></table></body></html>"); final NpcHtmlMessage ms = new NpcHtmlMessage(); ms.setHtml(html.toString()); activeChar.sendPacket(ms); } else { activeChar.sendMessage("Cannot find instance " + instance); } } else { activeChar.sendMessage("Invalid instance number."); } } catch (Exception e) { activeChar.sendMessage("Usage //instance_spawns <instance_number>"); } } else if (command.startsWith("admin_unspawnall")) { Broadcast.toAllOnlinePlayers( SystemMessage.getSystemMessage(SystemMessageId.NPC_SERVER_NOT_OPERATING)); RaidBossSpawnManager.getInstance().cleanUp(); DayNightSpawnManager.getInstance().cleanUp(); L2World.getInstance().deleteVisibleNpcSpawns(); AdminTable.getInstance().broadcastMessageToGMs("NPC Unspawn completed!"); } else if (command.startsWith("admin_spawnday")) { DayNightSpawnManager.getInstance().spawnDayCreatures(); } else if (command.startsWith("admin_spawnnight")) { DayNightSpawnManager.getInstance().spawnNightCreatures(); } else if (command.startsWith("admin_respawnall") || command.startsWith("admin_spawn_reload")) { // make sure all spawns are deleted RaidBossSpawnManager.getInstance().cleanUp(); DayNightSpawnManager.getInstance().cleanUp(); L2World.getInstance().deleteVisibleNpcSpawns(); // now respawn all NpcData.getInstance().load(); SpawnTable.getInstance().load(); RaidBossSpawnManager.getInstance().load(); AutoSpawnHandler.getInstance().reload(); SevenSigns.getInstance().spawnSevenSignsNPC(); QuestManager.getInstance().reloadAllScripts(); AdminTable.getInstance().broadcastMessageToGMs("NPC Respawn completed!"); } else if (command.startsWith("admin_spawn_monster") || command.startsWith("admin_spawn")) { StringTokenizer st = new StringTokenizer(command, " "); try { String cmd = st.nextToken(); String id = st.nextToken(); int respawnTime = 0; int mobCount = 1; if (st.hasMoreTokens()) { mobCount = Integer.parseInt(st.nextToken()); } if (st.hasMoreTokens()) { respawnTime = Integer.parseInt(st.nextToken()); } if (cmd.equalsIgnoreCase("admin_spawn_once")) { spawnMonster(activeChar, id, respawnTime, mobCount, false); } else { spawnMonster(activeChar, id, respawnTime, mobCount, true); } } catch (Exception e) { // Case of wrong or missing monster data AdminHtml.showAdminHtml(activeChar, "spawns.htm"); } } else if (command.startsWith("admin_list_spawns") || command.startsWith("admin_list_positions")) { int npcId = 0; int teleportIndex = -1; try { // admin_list_spawns x[xxxx] x[xx] String[] params = command.split(" "); Pattern pattern = Pattern.compile("[0-9]*"); Matcher regexp = pattern.matcher(params[1]); if (regexp.matches()) { npcId = Integer.parseInt(params[1]); } else { params[1] = params[1].replace('_', ' '); npcId = NpcData.getInstance().getTemplateByName(params[1]).getId(); } if (params.length > 2) { teleportIndex = Integer.parseInt(params[2]); } } catch (Exception e) { activeChar.sendMessage("Command format is //list_spawns <npcId|npc_name> [tele_index]"); } if (command.startsWith("admin_list_positions")) { findNPCInstances(activeChar, npcId, teleportIndex, true); } else { findNPCInstances(activeChar, npcId, teleportIndex, false); } } return true; }
private static final boolean validateGateCondition(L2PcInstance clanLeader, L2PcInstance player) { if (clanLeader.isAlikeDead()) { // Need retail message if there's one. player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet."); return false; } if (clanLeader.isInStoreMode()) { // Need retail message if there's one. player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet."); return false; } if (clanLeader.isRooted() || clanLeader.isInCombat()) { // Need retail message if there's one. player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet."); return false; } if (clanLeader.isInOlympiadMode()) { // Need retail message if there's one. player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet."); return false; } if (clanLeader.isFestivalParticipant()) { // Need retail message if there's one. player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet."); return false; } if (clanLeader.inObserverMode()) { // Need retail message if there's one. player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet."); return false; } if (clanLeader.isInsideZone(L2Character.ZONE_NOSUMMONFRIEND)) { // Need retail message if there's one. player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet."); return false; } if (clanLeader.getInstanceId() > 0) { if (!Config.ALLOW_SUMMON_TO_INSTANCE || InstanceManager.getInstance().getInstance(player.getInstanceId()).isSummonAllowed()) { // Need retail message if there's one. player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet."); return false; } } if (player.isIn7sDungeon()) { final int targetCabal = SevenSigns.getInstance().getPlayerCabal(clanLeader.getObjectId()); if (SevenSigns.getInstance().isSealValidationPeriod()) { if (targetCabal != SevenSigns.getInstance().getCabalHighestScore()) { // Need retail message if there's one. player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet."); return false; } } else { if (targetCabal == SevenSigns.CABAL_NULL) { // Need retail message if there's one. player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet."); return false; } } } if (!TvTEvent.onEscapeUse(player.getObjectId())) { player.sendMessage("You on TvT Event, teleporting disabled."); return false; } if (!TvTEvent.onEscapeUse(clanLeader.getObjectId())) { // Need retail message if there's one. player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet."); return false; } return true; }