@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); } }
@Override public void onBypassFeedback(L2PcInstance player, String command) { if (command.equalsIgnoreCase("start_mission") && Config.ALLOW_JAILMANAGER) { NpcHtmlMessage html = new NpcHtmlMessage(getObjectId()); html.setFile("data/html/mods/jail/mission.htm"); html.replace("%objectId%", String.valueOf(getObjectId())); html.replace("%playername%", player.getName()); html.replace("%amount%", String.valueOf(Config.REQUIRED_JAIL_POINTS)); html.replace("%npcname%", String.valueOf(getName())); player.sendPacket(html); if (player.isDead() || player.isFakeDeath()) { player.sendMessage( Message.getMessage(player, Message.MessageId.MSG_NOT_ALLOWED_AT_THE_MOMENT)); return; } } else if (command.equalsIgnoreCase("check_points") && player.isInJailMission()) { NpcHtmlMessage html2 = new NpcHtmlMessage(getObjectId()); html2.setFile("data/html/mods/jail/points.htm"); html2.replace("%objectId%", String.valueOf(getObjectId())); html2.replace("%points%", String.valueOf(player.getJailPoints())); html2.replace("%rest%", String.valueOf(Config.REQUIRED_JAIL_POINTS - player.getJailPoints())); html2.replace("%npcname%", String.valueOf(getName())); player.sendPacket(html2); if (player.isDead() || player.isFakeDeath()) { player.sendMessage( Message.getMessage(player, Message.MessageId.MSG_NOT_ALLOWED_AT_THE_MOMENT)); return; } } else if (command.equalsIgnoreCase("get_mission")) { if (player.isInJailMission()) { WindowService.sendWindow(player, "data/html/mods/jail/", "mission_already.htm"); return; } player.setIsInJailMission(true); PlaySound ps = new PlaySound( 0, "ItemSound2.race_start", 0, player.getObjectId(), player.getX(), player.getY(), player.getZ()); player.sendPacket(ps); WindowService.sendWindow(player, "data/html/mods/jail/", "started.htm"); if (player.isDead() || player.isFakeDeath()) { player.sendMessage( Message.getMessage(player, Message.MessageId.MSG_NOT_ALLOWED_AT_THE_MOMENT)); return; } } else if (command.equalsIgnoreCase("finish_mission")) { if (!player.isInJailMission()) { WindowService.sendWindow(player, "data/html/mods/jail/", "notstarted.htm"); return; } if (player.getJailPoints() < Config.REQUIRED_JAIL_POINTS) { WindowService.sendWindow(player, "data/html/mods/jail/", "notcompleted.htm"); return; } if (player.isDead() || player.isFakeDeath()) { player.sendMessage( Message.getMessage(player, Message.MessageId.MSG_NOT_ALLOWED_AT_THE_MOMENT)); return; } PlaySound ps = new PlaySound( 0, "ItemSound.quest_finish", 0, player.getObjectId(), player.getX(), player.getY(), player.getZ()); player.sendPacket(ps); WindowService.sendWindow(player, "data/html/mods/jail/", "completed.htm"); try { Thread.sleep(Util.convertSecondsToMiliseconds(5)); } catch (Throwable t) { _log.error("Error, L2JailManagerInstance, reason: " + t.getMessage()); } player.setInJail(false, 0); player.resetJailPoints(); player.sendMessage(Message.getMessage(player, Message.MessageId.MSG_JAIL_POINTS_RESET)); player.setIsInJailMission(false); } super.onBypassFeedback(player, command); }
@Override public void onBypassFeedback(L2PcInstance player, String command) { if (command.startsWith("Chat")) { int val = 0; try { val = Integer.parseInt(command.substring(5)); } catch (IndexOutOfBoundsException ioobe) { } catch (NumberFormatException nfe) { } showChatWindow(player, val); return; } else if (command.startsWith("ExchangeKE")) { String filename = null; int item; int i0 = Rnd.get(100); if (i0 < 5) { int i1 = Rnd.get(100); if (i1 < 5) item = 9931; // Red Talisman of Meditation else if (i1 <= 50) item = 9932; // Blue Talisman - Divine Protection else if (i1 <= 75) item = 10416; // Blue Talisman - Explosion else item = 10417; // Blue Talisman - Magic Explosion } else if (i0 <= 15) { switch (Rnd.get(5)) { case 1: // Red Talisman of Minimum Clarity item = 9917; break; case 2: // Red Talisman of Maximum Clarity item = 9918; break; case 3: // Red Talisman of Mental Regeneration item = 9928; break; case 4: // Blue Talisman of Protection item = 9929; break; default: // Blue Talisman of Invisibility item = 9920; } } else if (i0 <= 30) { switch (Rnd.get(8)) { case 1: // Blue Talisman of Defense item = 9916; break; case 2: // Blue Talisman of Defense item = 9916; break; case 3: // Blue Talisman of Healing item = 9924; break; case 4: // Red Talisman of Recovery item = 9925; break; case 5: // Blue Talisman of Defense item = 9926; break; case 6: // Blue Talisman of Magic Defense item = 9927; break; case 7: // Red Talisman - Life Force item = 10518; break; default: // Blue Talisman - Greater Healing item = 10424; } } else { switch (Rnd.get(46)) { case 0: // Blue Talisman of Power item = 9914; break; case 1: // Blue Talisman of Wild Magic item = 9915; break; case 2: // Blue Talisman of Invisibility item = 9920; break; case 3: // Blue Talisman of Invisibility item = 9920; break; case 4: // Blue Talisman - Shield Protection item = 9921; break; case 5: // Black Talisman - Mending item = 9922; break; case 6: // Yellow Talisman of Power item = 9933; break; case 7: // Yellow Talisman of Violent Haste item = 9934; break; case 8: // Yellow Talisman of Arcane Defense item = 9935; break; case 9: // Yellow Talisman of Arcane Power item = 9936; break; case 10: // Yellow Talisman of Arcane Haste item = 9937; break; case 11: // Yellow Talisman of Accuracy item = 9938; break; case 12: // Yellow Talisman of Defense item = 9939; break; case 13: // Yellow Talisman of Alacrity item = 9940; break; case 14: // Yellow Talisman of Speed item = 9941; break; case 15: // Yellow Talisman of Critical Reduction item = 9942; break; case 16: // Yellow Talisman of Critical Damage item = 9943; break; case 17: // Yellow Talisman of Critical Dodging item = 9944; break; case 18: // Yellow Talisman of Evasion item = 9945; break; case 19: // Yellow Talisman of Healing item = 9946; break; case 20: // Yellow Talisman of CP Regeneration item = 9947; break; case 21: // Yellow Talisman of Physical Regeneration item = 9948; break; case 22: // Yellow Talisman of Mental Regeneration item = 9949; break; case 23: // Grey Talisman of Weight Training item = 9950; break; case 24: // White Talisman of Protection item = 9965; break; case 25: // Orange Talisman - Hot Springs CP Potion item = 9952; break; case 26: // Orange Talisman - Elixir of Life item = 9953; break; case 27: // Orange Talisman - Elixir of Mental Strength item = 9954; break; case 28: // Black Talisman - Vocalization item = 9955; break; case 29: // Black Talisman - Arcane Freedom item = 9956; break; case 30: // Black Talisman - Physical Freedom item = 9957; break; case 31: // Black Talisman - Rescue item = 9958; break; case 32: // Black Talisman - Free Speech item = 9959; break; case 33: // White Talisman of Bravery item = 9960; break; case 34: // White Talisman of Motion item = 9961; break; case 35: // White Talisman of Grounding item = 9962; break; case 36: // White Talisman of Attention item = 9963; break; case 37: // White Talisman of Bandages item = 9964; break; case 38: // White Talisman - Storm item = 10418; break; case 39: // White Talisman - Water item = 10420; break; case 40: // White Talisman - Earth item = 10519; break; case 41: // White Talisman - Light item = 10422; break; case 42: // Blue Talisman - Self-Destruction item = 10423; break; case 43: // White Talisman - Darkness item = 10419; break; default: // White Talisman - Fire item = 10421; } } if (player.destroyItemByItemId("ExchangeKE", 9912, 10, this, false)) { SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.S2_S1_DISAPPEARED); msg.addItemName(9912); msg.addNumber(10); player.sendPacket(msg); player.addItem("ExchangeKE", item, 1, player, true); filename = "data/html/castlemagician/magician-KE-Exchange.htm"; } else filename = "data/html/castlemagician/magician-no-KE.htm"; showChatWindow(player, filename); return; } else if (command.equals("gotoleader")) { if (player.getClan() != null) { L2PcInstance clanLeader = player.getClan().getLeader().getPlayerInstance(); if (clanLeader == null) return; if (clanLeader.getFirstEffect(L2EffectType.CLAN_GATE) != null) { if (!validateGateCondition(clanLeader, player)) return; player.teleToLocation(clanLeader.getX(), clanLeader.getY(), clanLeader.getZ(), false); return; } String filename = "data/html/castlemagician/magician-nogate.htm"; showChatWindow(player, filename); } return; } else if (command.equals("subskills")) { if (player.getClan() != null) { if (player.isClanLeader()) { AcquireSkillList skilllist = new AcquireSkillList(SkillType.SubClass); FastList<L2SkillLearn> list = SkillTreesData.getInstance().getAvailableSubPledgeSkills(player.getClan()); if (list.isEmpty()) { player.sendPacket(SystemMessageId.NO_MORE_SKILLS_TO_LEARN); return; } for (L2SkillLearn skillLearn : list) { skilllist.addSkill( skillLearn.getSkillId(), skillLearn.getSkillLevel(), skillLearn.getSkillLevel(), skillLearn.getLevelUpSp(), 0); } player.sendPacket(skilllist); } else { String filename = "data/html/castlemagician/magician-nosquad.htm"; showChatWindow(player, filename); } } } else super.onBypassFeedback(player, command); }