Advertisement
Sarada-L2

Comando .sub para Frozen Yo: Sarada

May 11th, 2021
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.86 KB | None | 0 0
  1. diff --git a/config/CustomMods/Commands.ini b/config/CustomMods/Commands.ini
  2. new file mode 100644
  3. index 0000000..e4ae49c
  4. --- /dev/null
  5. +++ b/config/CustomMods/Commands.ini
  6. @@ -0,0 +1,6 @@
  7. +#=============================================================
  8. +# Command SubClass
  9. +#=============================================================
  10. +# Enable Command SubClass use -> .sub
  11. +# Retail: False
  12. +CustomSubClassCommand = True
  13. diff --git a/head-src/com/l2jfrozen/Config.java b/head-src/com/l2jfrozen/Config.java
  14. index 427d937..2cb8088 100644
  15. --- a/head-src/com/l2jfrozen/Config.java
  16. +++ b/head-src/com/l2jfrozen/Config.java
  17. @@ -81,6 +81,7 @@
  18. public static List<int[]> RENEWAL_ITEMS_NEWBIE = new ArrayList<>();
  19. public static int MIN_PVP_TO_PARTICIPATE_OLYMPIADAS;
  20. public static int MIN_PK_TO_PARTICIPATE_OLYMPIADAS;
  21. + public static boolean CUSTOM_SUB_CLASS_COMMAND;
  22. public static int ITEM_RENEWAL_NEWBIEID;
  23. public static boolean ENABLE_ENCHANT_ANNOUNCE;
  24. public static int ENCHANT_ANNOUNCE_LEVEL;
  25. @@ -357,7 +358,7 @@
  26. final InputStream is = new FileInputStream(new File(COMMANDS));
  27. Commands.load(is);
  28. is.close();
  29. + CUSTOM_SUB_CLASS_COMMAND = Boolean.parseBoolean(Commands.getProperty("CustomSubClassCommand", "True"));
  30. COMMAND_BUFF_ENABLE = Boolean.parseBoolean(Commands.getProperty("EnableCommandBuff", "True"));
  31. COMMAND_BUFF_ISVIP = Boolean.parseBoolean(Commands.getProperty("EnableCommandBuffVIP", "True"));
  32. MESSAGE_VIP = Commands.getProperty("ScreenVIPMessageText", "Forbidden to Use Enchant near the bank!");
  33. diff --git a/head-src/com/l2jfrozen/gameserver/GameServer.java b/head-src/com/l2jfrozen/gameserver/GameServer.java
  34. index 52d0393..8b80d44 100644
  35. --- a/head-src/com/l2jfrozen/gameserver/GameServer.java
  36. +++ b/head-src/com/l2jfrozen/gameserver/GameServer.java
  37. @@ -90,6 +90,8 @@
  38. import com.l2jfrozen.gameserver.handler.SkillHandler;
  39. import com.l2jfrozen.gameserver.handler.UserCommandHandler;
  40. import com.l2jfrozen.gameserver.handler.VoicedCommandHandler;
  41. +import com.l2jfrozen.gameserver.handler.custom.CustomBypassHandler;
  42. +import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.Sub;
  43. import com.l2jfrozen.gameserver.idfactory.IdFactory;
  44. import com.l2jfrozen.gameserver.managers.AuctionManager;
  45. import com.l2jfrozen.gameserver.managers.AutoSaveManager;
  46. @@ -255,6 +257,13 @@
  47. LOGGER.info("Could not read object IDs from DB. Please Check Your Data.");
  48. throw new Exception("Could not initialize the ID factory");
  49. }
  50. + if (Config.CUSTOM_SUB_CLASS_COMMAND)
  51. + {
  52. + Sub handle4 = new Sub();
  53. + CustomBypassHandler.getInstance().registerCustomBypassHandler(handle4);
  54. + VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new Sub());
  55. + LOGGER.info("Command .sub - Enabled");
  56. + }
  57. StaticObjects.getInstance();
  58. TeleportLocationTable.getInstance();
  59. PartyMatchWaitingList.getInstance();
  60. diff --git a/head-src/com/l2jfrozen/gameserver/handler/VoicedCommandHandler.java b/head-src/com/l2jfrozen/gameserver/handler/VoicedCommandHandler.java
  61. index 436a078..bfe4a1f 100644
  62. --- a/head-src/com/l2jfrozen/gameserver/handler/VoicedCommandHandler.java
  63. +++ b/head-src/com/l2jfrozen/gameserver/handler/VoicedCommandHandler.java
  64. @@ -22,8 +22,6 @@
  65.  
  66. import java.util.Map;
  67. import org.apache.log4j.Logger;
  68.  
  69. import com.l2jfrozen.Config;
  70. @@ -40,6 +38,7 @@
  71. import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.Online;
  72. import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.Shiff_Mod;
  73. import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.StatsCmd;
  74. +import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.Sub;
  75. import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.TvTCmd;
  76. import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.VersionCmd;
  77. import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.VoicedBossSpawn;
  78. @@ -50,6 +49,8 @@
  79. import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.Voting;
  80. import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.Wedding;
  81.  
  82. /**
  83. * This class ...
  84. * @version $Revision: 1.1.4.6 $ $Date: 2009/05/12 19:44:09 $
  85. @@ -78,6 +79,10 @@
  86. registerVoicedCommandHandler(new BossEventCMD());
  87. registerVoicedCommandHandler(new Shiff_Mod());
  88. registerVoicedCommandHandler(new Voting());
  89. + if (Config.CUSTOM_SUB_CLASS_COMMAND)
  90. + {
  91. + registerVoicedCommandHandler(new Sub());
  92. + }
  93. if(Config.ENABLE_COMMAND_XPON_OFF)
  94. {
  95. registerVoicedCommandHandler(new GainXpSp());
  96. diff --git a/head-src/com/l2jfrozen/gameserver/handler/voicedcommandhandlers/Sub.java b/head-src/com/l2jfrozen/gameserver/handler/voicedcommandhandlers/Sub.java
  97. new file mode 100644
  98. index 0000000..b430a24
  99. --- /dev/null
  100. +++ b/head-src/com/l2jfrozen/gameserver/handler/voicedcommandhandlers/Sub.java
  101. @@ -0,0 +1,554 @@
  102. +/*
  103. + * This program is free software; you can redistribute it and/or modify
  104. + * it under the terms of the GNU General Public License as published by
  105. + * the Free Software Foundation; either version 2, or (at your option)
  106. + * any later version.
  107. + *
  108. + * This program is distributed in the hope that it will be useful,
  109. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  110. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  111. + * GNU General Public License for more details.
  112. + *
  113. + * You should have received a copy of the GNU General Public License
  114. + * along with this program; if not, write to the Free Software
  115. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  116. + * 02111-1307, USA.
  117. + *
  118. + * http://www.gnu.org/copyleft/gpl.html
  119. + */
  120. +package com.l2jfrozen.gameserver.handler.voicedcommandhandlers;
  121. +
  122. +import java.util.Iterator;
  123. +import java.util.Set;
  124. +
  125. +import com.l2jfrozen.Config;
  126. +import com.l2jfrozen.gameserver.datatables.sql.CharTemplateTable;
  127. +import com.l2jfrozen.gameserver.handler.ICustomByPassHandler;
  128. +import com.l2jfrozen.gameserver.handler.IVoicedCommandHandler;
  129. +import com.l2jfrozen.gameserver.model.L2Character;
  130. +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  131. +import com.l2jfrozen.gameserver.model.base.ClassId;
  132. +import com.l2jfrozen.gameserver.model.base.PlayerClass;
  133. +import com.l2jfrozen.gameserver.model.base.SubClass;
  134. +import com.l2jfrozen.gameserver.model.entity.olympiad.Olympiad;
  135. +import com.l2jfrozen.gameserver.model.quest.QuestState;
  136. +import com.l2jfrozen.gameserver.network.SystemMessageId;
  137. +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
  138. +import com.l2jfrozen.gameserver.network.serverpackets.SystemMessage;
  139. +
  140. +import javolution.text.TextBuilder;
  141. +
  142. +public class Sub implements IVoicedCommandHandler, ICustomByPassHandler
  143. +{
  144. + private static final String PARENT_DIR = "data/html/mods/sub/";
  145. +
  146. + private static final String[] VOICED_COMMANDS =
  147. + {
  148. + "sub",
  149. + };
  150. +
  151. + @Override
  152. + public boolean useVoicedCommand(String command, L2PcInstance player, String target)
  153. + {
  154. + if (!player.isInsideZone(L2Character.ZONE_PEACE))
  155. + {
  156. + player.sendMessage("Command is not available in this area.");
  157. + return false;
  158. + }
  159. +
  160. + if (command.equalsIgnoreCase("sub"))
  161. + {
  162. + showHtm(player);
  163. + }
  164. + return true;
  165. + }
  166. +
  167. + private void showHtm(L2PcInstance player)
  168. + {
  169. + NpcHtmlMessage htm = new NpcHtmlMessage(player.getLastQuestNpcObject());
  170. + htm.setFile(PARENT_DIR + "SubClass.htm");
  171. + player.sendPacket(htm);
  172. + }
  173. +
  174. + @Override
  175. + public String[] getVoicedCommandList()
  176. + {
  177. + return VOICED_COMMANDS;
  178. + }
  179. +
  180. + @Override
  181. + public String[] getByPassCommands()
  182. + {
  183. + return new String []
  184. + {
  185. + "sub_0",
  186. + "sub_1",
  187. + "sub_2",
  188. + "sub_3",
  189. + "sub_4",
  190. + "sub_5",
  191. + "sub_6",
  192. + "sub_7"
  193. + };
  194. + }
  195. +
  196. + private enum CommandEnum
  197. + {
  198. + sub_0,
  199. + sub_1,
  200. + sub_2,
  201. + sub_3,
  202. + sub_4,
  203. + sub_5,
  204. + sub_6,
  205. + sub_7
  206. + }
  207. +
  208. + @Override
  209. + public void handleCommand(String command, L2PcInstance player, String parameters)
  210. + {
  211. + CommandEnum comm = CommandEnum.valueOf(command);
  212. +
  213. + // Fix exploit stuck subclass and skills
  214. + if (player.isLearningSkill() || player.isLocked())
  215. + return;
  216. +
  217. + // Subclasses may not be changed while a skill is in use.
  218. + if (player.isCastingNow() || player.isAllSkillsDisabled())
  219. + {
  220. + player.sendPacket(new SystemMessage(SystemMessageId.SUBCLASS_NO_CHANGE_OR_CREATE_WHILE_SKILL_IN_USE));
  221. + return;
  222. + }
  223. +
  224. + if (player.isInCombat())
  225. + {
  226. + player.sendMessage("You can't change Subclass when you are in combat.");
  227. + return;
  228. + }
  229. +
  230. + if (player.isCursedWeaponEquiped())
  231. + {
  232. + player.sendMessage("You can`t change Subclass while Cursed weapon equiped!");
  233. + return;
  234. + }
  235. +
  236. + NpcHtmlMessage html = new NpcHtmlMessage(player.getLastQuestNpcObject());
  237. + TextBuilder content = new TextBuilder("<html><body>");
  238. + Set<PlayerClass> subsAvailable;
  239. +
  240. + switch(comm)
  241. + {
  242. + case sub_0:
  243. + {
  244. + showHtm(player);
  245. + return;
  246. + }
  247. + case sub_1:
  248. + if (player.getTotalSubClasses() == Config.ALLOWED_SUBCLASS)
  249. + {
  250. + player.sendMessage("You can now only change one of your current sub classes.");
  251. + return;
  252. + }
  253. +
  254. + subsAvailable = getAvailableSubClasses(player);
  255. +
  256. + if (subsAvailable != null && !subsAvailable.isEmpty())
  257. + {
  258. + content.append("Add Subclass:<br>Which sub class do you wish to add?<br>");
  259. +
  260. + for (PlayerClass subClass : subsAvailable)
  261. + {
  262. + content.append("<a action=\"bypass -h custom_sub_4 "+subClass.ordinal()+"\" msg=\"1268;" + formatClassForDisplay(subClass) + "\">" + formatClassForDisplay(subClass) + "</a><br>");
  263. + }
  264. + }
  265. + else
  266. + {
  267. + player.sendMessage("There are no sub classes available at this time.");
  268. + return;
  269. + }
  270. + break;
  271. + case sub_2: // Change Class - Initial
  272. + content.append("Change Subclass:<br>");
  273. +
  274. + final int baseClassId = player.getBaseClass();
  275. +
  276. + if (player.getSubClasses().isEmpty())
  277. + {
  278. + content.append("You can't change sub classes when you don't have a sub class to begin with.<br>" + "<a action=\"bypass -h custom_sub_1\">Add subclass.</a>");
  279. + }
  280. + else
  281. + {
  282. + content.append("Which class would you like to switch to?<br>");
  283. +
  284. + if(baseClassId == player.getActiveClass())
  285. + {
  286. + content.append(CharTemplateTable.getClassNameById(baseClassId) + "&nbsp;<font color=\"LEVEL\">(Base Class)</font><br><br>");
  287. + }
  288. + else
  289. + {
  290. + content.append("<a action=\"bypass -h custom_sub_5 0\">" + CharTemplateTable.getClassNameById(baseClassId) + "</a>&nbsp;" + "<font color=\"LEVEL\">(Base Class)</font><br><br>");
  291. + }
  292. +
  293. + for(Iterator<SubClass> subList = iterSubClasses(player); subList.hasNext();)
  294. + {
  295. + SubClass subClass = subList.next();
  296. + int subClassId = subClass.getClassId();
  297. +
  298. + if(subClassId == player.getActiveClass())
  299. + {
  300. + content.append(CharTemplateTable.getClassNameById(subClassId) + "<br>");
  301. + }
  302. + else
  303. + {
  304. + content.append("<a action=\"bypass -h custom_sub_5 " +subClass.getClassIndex()+ "\">" + CharTemplateTable.getClassNameById(subClassId) + "</a><br>");
  305. + }
  306. + }
  307. + }
  308. + break;
  309. + case sub_3: // Change/Cancel Subclass - Initial
  310. + content.append("Change Subclass:<br>Which of the following sub classes would you like to change?<br>");
  311. + int classIndex = 1;
  312. +
  313. + for (Iterator<SubClass> subList = iterSubClasses(player); subList.hasNext();)
  314. + {
  315. + SubClass subClass = subList.next();
  316. + content.append("Sub-class " + classIndex + "<br1>");
  317. + content.append("<a action=\"bypass -h custom_sub_6 " + subClass.getClassIndex() + "\">" + CharTemplateTable.getClassNameById(subClass.getClassId()) + "</a><br>");
  318. + classIndex++;
  319. + }
  320. + content.append("<br>If you change a sub class, you'll start at level 40 after the 2nd class transfer.");
  321. + break;
  322. + case sub_4: // Add Subclass - Action (Subclass 4 x[x])
  323. + int flag = Integer.parseInt(parameters.trim());
  324. +
  325. + if(player.isLearningSkill() || player.isLocked())
  326. + return;
  327. +
  328. + player.setLocked(true);
  329. + boolean allowAddition = true;
  330. +
  331. + // Subclass exploit fix during add subclass
  332. + if (!player.getFloodProtectors().getSubclass().tryPerformAction("add subclass"))
  333. + {
  334. + player.setLocked(false);
  335. + return;
  336. + }
  337. +
  338. + // You can't add Subclass when you are registered in Events (TVT, CTF, DM)
  339. + if(player._inEventTvT || player._inEventCTF || player._inEventDM)
  340. + {
  341. + player.sendMessage("You can't add a subclass while in an event.");
  342. + player.setLocked(false);
  343. + return;
  344. + }
  345. +
  346. + // Check player level
  347. + if(player.getLevel() < 75)
  348. + {
  349. + player.sendMessage("You may not add a new sub class before you are level 75 on your previous class.");
  350. + allowAddition = false;
  351. + }
  352. +
  353. + // You can't add Subclass when you are registered in Olympiad
  354. + if(Olympiad.getInstance().isRegisteredInComp(player) || player.getOlympiadGameId() > 0)
  355. + {
  356. + player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_ALREADY_BEEN_REGISTERED_IN_A_WAITING_LIST_OF_AN_EVENT));
  357. + player.setLocked(false);
  358. + return;
  359. + }
  360. +
  361. + if (allowAddition)
  362. + {
  363. + if(!player.getSubClasses().isEmpty())
  364. + {
  365. + for(Iterator<SubClass> subList = iterSubClasses(player); subList.hasNext();)
  366. + {
  367. + SubClass subClass = subList.next();
  368. +
  369. + if(subClass.getLevel() < 75)
  370. + {
  371. + player.sendMessage("You may not add a new sub class before you are level 75 on your previous sub class.");
  372. + allowAddition = false;
  373. + break;
  374. + }
  375. + }
  376. + }
  377. + }
  378. +
  379. + /*
  380. + * If quest checking is enabled, verify if the character has completed the Mimir's Elixir (Path to Subclass)
  381. + * and Fate's Whisper (A Grade Weapon) quests by checking for instances of their unique reward items.
  382. + *
  383. + * If they both exist, remove both unique items and continue with adding the sub-class.
  384. + */
  385. + if(!Config.ALT_GAME_SUBCLASS_WITHOUT_QUESTS)
  386. + {
  387. +
  388. + QuestState qs = player.getQuestState("235_MimirsElixir");
  389. + if(qs == null || !qs.isCompleted())
  390. + {
  391. + player.sendMessage("You must have completed the Mimir's Elixir quest to continue adding your sub class.");
  392. + player.setLocked(false);
  393. + return;
  394. + }
  395. + qs = player.getQuestState("234_FatesWhisper");
  396. +
  397. + if(qs == null || !qs.isCompleted())
  398. + {
  399. + player.sendMessage("You must have completed the Fate's Whisper quest to continue adding your sub class.");
  400. + player.setLocked(false);
  401. + return;
  402. + }
  403. + }
  404. +
  405. + if (allowAddition)
  406. + {
  407. + String className = CharTemplateTable.getClassNameById(flag);
  408. +
  409. + if (!player.addSubClass(flag, player.getTotalSubClasses() + 1))
  410. + {
  411. + player.sendMessage("The sub class could not be added.");
  412. + player.setLocked(false);
  413. + return;
  414. + }
  415. +
  416. + player.setActiveClass(player.getTotalSubClasses());
  417. +
  418. + if(Config.CHECK_SKILLS_ON_ENTER && !Config.ALT_GAME_SKILL_LEARN)
  419. + {
  420. + player.checkAllowedSkills();
  421. + }
  422. +
  423. + content.append("Add Subclass:<br>The sub class of <font color=\"LEVEL\">" + className + "</font> has been added.");
  424. + player.sendPacket(new SystemMessage(SystemMessageId.CLASS_TRANSFER)); // Transfer to new class.
  425. + }
  426. + else
  427. + {
  428. + html.setFile("data/html/mods/sub/SubClass_Fail.htm");
  429. + }
  430. +
  431. + player.setLocked(false);
  432. + break;
  433. + case sub_5: // Change Class - Action
  434. + int flag2 = Integer.parseInt(parameters.trim());
  435. + // Fix exploit stuck subclass and skills
  436. + if(player.isLearningSkill() || player.isLocked())
  437. + return;
  438. +
  439. + player.setLocked(true);
  440. +
  441. + // Subclass exploit fix during change subclass
  442. + if (!player.getFloodProtectors().getSubclass().tryPerformAction("change subclass"))
  443. + {
  444. + player.setLocked(false);
  445. + return;
  446. + }
  447. +
  448. + // You can't change Subclass when you are registered in Events (TVT, CTF, DM)
  449. + if(player._inEventTvT || player._inEventCTF || player._inEventDM)
  450. + {
  451. + player.sendMessage("You can't change subclass while in an event.");
  452. + player.setLocked(false);
  453. + return;
  454. + }
  455. +
  456. + // You can't change Subclass when you are registered in Olympiad
  457. + if(Olympiad.getInstance().isRegisteredInComp(player) || player.getOlympiadGameId() > 0)
  458. + {
  459. + player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_ALREADY_BEEN_REGISTERED_IN_A_WAITING_LIST_OF_AN_EVENT));
  460. + player.setLocked(false);
  461. + return;
  462. + }
  463. +
  464. + player.setActiveClass(flag2);
  465. +
  466. + content.append("Change Subclass:<br>Your active sub class is now a <font color=\"LEVEL\">" + CharTemplateTable.getClassNameById(player.getActiveClass()) + "</font>.");
  467. +
  468. + player.sendPacket(new SystemMessage(SystemMessageId.SUBCLASS_TRANSFER_COMPLETED)); // Transfer completed.
  469. +
  470. + // check player skills
  471. + if(Config.CHECK_SKILLS_ON_ENTER && !Config.ALT_GAME_SKILL_LEARN)
  472. + {
  473. + player.checkAllowedSkills();
  474. + }
  475. +
  476. + player.setLocked(false);
  477. + break;
  478. + case sub_6: // Change/Cancel Subclass - Choice
  479. + int subIndex = Integer.parseInt(parameters.trim());
  480. + content.append("Please choose a sub class to change to. If the one you are looking for is not here, " + "please seek out the appropriate master for that class.<br>" + "<font color=\"LEVEL\">Warning!</font> All classes and skills for this class will be removed.<br><br>");
  481. +
  482. + subsAvailable = getAvailableSubClasses(player);
  483. +
  484. + if (subsAvailable != null && !subsAvailable.isEmpty())
  485. + {
  486. + for(PlayerClass subClass : subsAvailable)
  487. + {
  488. + content.append("<a action=\"bypass -h custom_sub_7 "+subIndex+" "+subClass.ordinal()+"\">" + formatClassForDisplay(subClass) + "</a><br>");
  489. + }
  490. + }
  491. + else
  492. + {
  493. + player.sendMessage("There are no sub classes available at this time.");
  494. + return;
  495. + }
  496. + break;
  497. + case sub_7:
  498. + String strNum = parameters;
  499. + String subIndexId = strNum.substring(0,1);
  500. + String subNewId = strNum.substring(2);
  501. +
  502. + int flag4 = Integer.parseInt(subIndexId);
  503. + int flag5 = Integer.parseInt(subNewId);
  504. +
  505. + if (player.isLearningSkill() || player.isLocked())
  506. + return;
  507. +
  508. + player.setLocked(true);
  509. +
  510. + // Subclass exploit fix during delete subclass
  511. + if (!player.getFloodProtectors().getSubclass().tryPerformAction("delete subclass"))
  512. + {
  513. + player.setLocked(false);
  514. + return;
  515. + }
  516. +
  517. + // You can't delete Subclass when you are registered in Events (TVT, CTF, DM)
  518. + if (player._inEventTvT || player._inEventCTF || player._inEventDM)
  519. + {
  520. + player.sendMessage("You can't delete a subclass while in an event.");
  521. + player.setLocked(false);
  522. + return;
  523. + }
  524. +
  525. + // You can't delete Subclass when you are registered in Olympiad
  526. + if (Olympiad.getInstance().isRegisteredInComp(player) || player.getOlympiadGameId() > 0)
  527. + {
  528. + player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_ALREADY_BEEN_REGISTERED_IN_A_WAITING_LIST_OF_AN_EVENT));
  529. + player.setLocked(false);
  530. + return;
  531. + }
  532. +
  533. + if (player.modifySubClass(flag4, flag5))
  534. + {
  535. + player.setActiveClass(flag4);
  536. +
  537. + content.append("Change Subclass:<br>Your sub class has been changed to <font color=\"LEVEL\">" + CharTemplateTable.getClassNameById(flag5) + "</font>.");
  538. +
  539. + player.sendPacket(new SystemMessage(SystemMessageId.ADD_NEW_SUBCLASS)); // Subclass added.
  540. +
  541. + // check player skills
  542. + if(Config.CHECK_SKILLS_ON_ENTER && !Config.ALT_GAME_SKILL_LEARN)
  543. + {
  544. + player.checkAllowedSkills();
  545. + }
  546. + }
  547. + else
  548. + {
  549. + player.setActiveClass(0); // Also updates _classIndex plus switching _classid to baseclass.
  550. +
  551. + if(Config.CHECK_SKILLS_ON_ENTER && !Config.ALT_GAME_SKILL_LEARN)
  552. + {
  553. + player.checkAllowedSkills();
  554. + }
  555. +
  556. + player.sendMessage("The sub class could not be added, you have been reverted to your base class.");
  557. + player.setLocked(false);
  558. + return;
  559. + }
  560. + player.setLocked(false);
  561. + break;
  562. + }
  563. +
  564. + content.append("</body></html>");
  565. +
  566. + if (content.length() > 10)
  567. + {
  568. + html.setHtml(content.toString());
  569. + }
  570. + player.sendPacket(html);
  571. + }
  572. +
  573. + private final Set<PlayerClass> getAvailableSubClasses(L2PcInstance player)
  574. + {
  575. + int charClassId = player.getBaseClass();
  576. +
  577. + if (charClassId >= 88)
  578. + {
  579. + charClassId = player.getClassId().getParent().ordinal();
  580. + }
  581. +
  582. + PlayerClass currClass = PlayerClass.values()[charClassId];
  583. +
  584. + /**
  585. + * If the race of your main class is Elf or Dark Elf, you may not select each class as a subclass to the other
  586. + * class, and you may not select Overlord and Warsmith class as a subclass. You may not select a similar class
  587. + * as the subclass. The occupations classified as similar classes are as follows: Treasure Hunter, Plainswalker
  588. + * and Abyss Walker Hawkeye, Silver Ranger and Phantom Ranger Paladin, Dark Avenger, Temple Knight and Shillien
  589. + * Knight Warlocks, Elemental Summoner and Phantom Summoner Elder and Shillien Elder Swordsinger and Bladedancer
  590. + * Sorcerer, Spellsinger and Spellhowler
  591. + */
  592. +
  593. + Set<PlayerClass> availSubs = currClass.getAvailableSubclasses(player);
  594. +
  595. + if (availSubs != null)
  596. + {
  597. + for(PlayerClass availSub : availSubs)
  598. + {
  599. + for(SubClass subClass : player.getSubClasses().values())
  600. + {
  601. + if(subClass.getClassId() == availSub.ordinal())
  602. + {
  603. + availSubs.remove(availSub);
  604. + }
  605. + }
  606. +
  607. + for(Iterator<SubClass> subList = iterSubClasses(player); subList.hasNext();)
  608. + {
  609. + SubClass prevSubClass = subList.next();
  610. + int subClassId = prevSubClass.getClassId();
  611. + if(subClassId >= 88)
  612. + {
  613. + subClassId = ClassId.values()[subClassId].getParent().getId();
  614. + }
  615. +
  616. + if(availSub.ordinal() == subClassId || availSub.ordinal() == player.getBaseClass())
  617. + {
  618. + availSubs.remove(PlayerClass.values()[availSub.ordinal()]);
  619. + }
  620. + }
  621. + }
  622. + }
  623. + return availSubs;
  624. + }
  625. +
  626. + /**
  627. + * Format class for display.
  628. + *
  629. + * @param className the class name
  630. + * @return the string
  631. + */
  632. + private final String formatClassForDisplay(PlayerClass className)
  633. + {
  634. + String classNameStr = className.toString();
  635. + char[] charArray = classNameStr.toCharArray();
  636. +
  637. + for(int i = 1; i < charArray.length; i++)
  638. + if(Character.isUpperCase(charArray[i]))
  639. + {
  640. + classNameStr = classNameStr.substring(0, i) + " " + classNameStr.substring(i);
  641. + }
  642. +
  643. + return classNameStr;
  644. + }
  645. + /**
  646. + * Iter sub classes.
  647. + *
  648. + * @param player the player
  649. + * @return the iterator
  650. + */
  651. + private Iterator<SubClass> iterSubClasses(L2PcInstance player)
  652. + {
  653. + return player.getSubClasses().values().iterator();
  654. + }
  655. +}
  656.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement