private final Set<PlayerClass> getAvailableSubClasses(L2PcInstance player) { final PlayerRace npcRace = getVillageMasterRace(); final ClassType npcTeachType = getVillageMasterTeachType(); // get player base class final int currentBaseId = player.getBaseClass(); final ClassId baseCID = ClassId.values()[currentBaseId]; // we need 2nd occupation ID final int baseClassId; if (baseCID.level() > 2) baseClassId = baseCID.getParent().ordinal(); else baseClassId = currentBaseId; PlayerClass currClass = PlayerClass.values()[baseClassId]; /** * If the race of your main class is Elf or Dark Elf, you may not select each class as a * subclass to the other class, and you may not select Overlord and Warsmith class as a * subclass. You may not select a similar class as the subclass. The occupations classified as * similar classes are as follows: Treasure Hunter, Plainswalker and Abyss Walker Hawkeye, * Silver Ranger and Phantom Ranger Paladin, Dark Avenger, Temple Knight and Shillien Knight * Warlocks, Elemental Summoner and Phantom Summoner Elder and Shillien Elder Swordsinger and * Bladedancer Sorcerer, Spellsinger and Spellhowler */ Set<PlayerClass> availSubs = currClass.getAvailableSubclasses(player); if (availSubs != null && !availSubs.isEmpty()) { for (PlayerClass availSub : availSubs) { for (SubClass subClass : player.getSubClasses().values()) if (subClass.getClassId() == availSub.ordinal()) { availSubs.remove(PlayerClass.values()[availSub.ordinal()]); } for (Iterator<SubClass> subList = iterSubClasses(player); subList.hasNext(); ) { SubClass prevSubClass = subList.next(); int subClassId = prevSubClass.getClassId(); if (subClassId >= 88) { subClassId = ClassId.values()[subClassId].getParent().getId(); } if (availSub.ordinal() == subClassId || availSub.ordinal() == player.getBaseClass()) { availSubs.remove(PlayerClass.values()[availSub.ordinal()]); } } if (npcRace == PlayerRace.Human || npcRace == PlayerRace.LightElf) { // If the master is human or light elf, ensure that fighter-type // masters only teach fighter classes, and priest-type masters // only teach priest classes etc. if (!availSub.isOfType(npcTeachType)) { availSubs.remove(availSub); } else if (!availSub.isOfRace(PlayerRace.Human) && !availSub.isOfRace(PlayerRace.LightElf)) { availSubs.remove(availSub); } } else { // If the master is not human and not light elf, // then remove any classes not of the same race as the master. if (npcRace != PlayerRace.Human && npcRace != PlayerRace.LightElf && !availSub.isOfRace(npcRace)) { availSubs.remove(availSub); } } } } currClass = null; return availSubs; }