Sarada-L2

Item Class L2jfrozen Adpt Yo: Sarada

Jun 18th, 2021 (edited)
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.18 KB | None | 0 0
  1. diff --git a/config/functions/l2jfrozen.properties b/config/functions/l2jfrozen.properties
  2. index b1eaa98..169b5ee 100644
  3. --- a/config/functions/l2jfrozen.properties
  4. +++ b/config/functions/l2jfrozen.properties
  5. @@ -281,4 +281,12 @@
  6. ProtectorSkillLevel = 13
  7. ProtectorSkillTime = 600
  8. # Npc Protector Message
  9. ProtectorMessage = Hey You!, Never Kill On This Area, Go Read The Rules!
  10. +
  11. +#=============================================================
  12. +# Item Class Change
  13. +#=============================================================
  14. +#Item Coin Class
  15. +ItemCard = 0
  16. +
  17. diff --git a/head-src/com/l2jfrozen/Config.java b/head-src/com/l2jfrozen/Config.java
  18. index 7f8d0ef..4b37abc 100644
  19. --- a/head-src/com/l2jfrozen/Config.java
  20. +++ b/head-src/com/l2jfrozen/Config.java
  21. @@ -2337,6 +2337,7 @@
  22. public static float DONATOR_ADENA_RATE;
  23. public static float DONATOR_DROP_RATE;
  24. public static float DONATOR_SPOIL_RATE;
  25. + public static int ITEM_CLASS_ID;
  26. public static boolean CUSTOM_SPAWNLIST_TABLE;
  27. public static boolean SAVE_GMSPAWN_ON_CUSTOM;
  28. public static boolean DELETE_GMSPAWN_ON_CUSTOM;
  29. @@ -2441,6 +2442,7 @@
  30. is.close();
  31.  
  32. /** Custom Tables **/
  33. + ITEM_CLASS_ID = Integer.parseInt(L2JFrozenSettings.getProperty("ItemCard", "0"));
  34. CUSTOM_SPAWNLIST_TABLE = Boolean.valueOf(L2JFrozenSettings.getProperty("CustomSpawnlistTable", "True"));
  35. SAVE_GMSPAWN_ON_CUSTOM = Boolean.valueOf(L2JFrozenSettings.getProperty("SaveGmSpawnOnCustom", "True"));
  36. DELETE_GMSPAWN_ON_CUSTOM = Boolean.valueOf(L2JFrozenSettings.getProperty("DeleteGmSpawnOnCustom", "True"));
  37. diff --git a/head-src/com/l2jfrozen/gameserver/handler/ItemHandler.java b/head-src/com/l2jfrozen/gameserver/handler/ItemHandler.java
  38. index 8dad568..2264488 100644
  39. --- a/head-src/com/l2jfrozen/gameserver/handler/ItemHandler.java
  40. +++ b/head-src/com/l2jfrozen/gameserver/handler/ItemHandler.java
  41. @@ -35,6 +35,7 @@
  42. import com.l2jfrozen.gameserver.handler.itemhandlers.CharChangePotions;
  43. import com.l2jfrozen.gameserver.handler.itemhandlers.ChestKey;
  44. import com.l2jfrozen.gameserver.handler.itemhandlers.ChristmasTree;
  45. +import com.l2jfrozen.gameserver.handler.itemhandlers.ClassItem;
  46. import com.l2jfrozen.gameserver.handler.itemhandlers.CrystalCarol;
  47. import com.l2jfrozen.gameserver.handler.itemhandlers.Crystals;
  48. import com.l2jfrozen.gameserver.handler.itemhandlers.CustomPotions;
  49. @@ -110,6 +111,7 @@
  50. private ItemHandler()
  51. {
  52. _datatable = new TreeMap<>();
  53. + registerItemHandler(new ClassItem());
  54. registerItemHandler(new ScrollOfEscape());
  55. registerItemHandler(new ScrollOfResurrection());
  56. registerItemHandler(new SoulShots());
  57. diff --git a/head-src/com/l2jfrozen/gameserver/handler/itemhandlers/ClassItem.java b/head-src/com/l2jfrozen/gameserver/handler/itemhandlers/ClassItem.java
  58. new file mode 100644
  59. index 0000000..f6f485d
  60. --- /dev/null
  61. +++ b/head-src/com/l2jfrozen/gameserver/handler/itemhandlers/ClassItem.java
  62. @@ -0,0 +1,58 @@
  63. +/*
  64. + * This program is free software: you can redistribute it and/or modify it under
  65. + * the terms of the GNU General Public License as published by the Free Software
  66. + * Foundation, either version 3 of the License, or (at your option) any later
  67. + * version.
  68. + *
  69. + * This program is distributed in the hope that it will be useful, but WITHOUT
  70. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  71. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  72. + * details.
  73. + *
  74. + * You should have received a copy of the GNU General Public License along with
  75. + * this program. If not, see <http://www.gnu.org/licenses/>.
  76. + */
  77. +package com.l2jfrozen.gameserver.handler.itemhandlers;
  78. +
  79. +import com.l2jfrozen.Config;
  80. +import com.l2jfrozen.gameserver.handler.IItemHandler;
  81. +import com.l2jfrozen.gameserver.model.L2Character;
  82. +import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance;
  83. +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  84. +import com.l2jfrozen.gameserver.model.actor.instance.L2PlayableInstance;
  85. +import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
  86. +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
  87. +
  88. +public class ClassItem implements IItemHandler
  89. +{
  90. + private static final int[] ITEM_IDS = { Config.ITEM_CLASS_ID };
  91. +
  92. + @Override
  93. + public void useItem(final L2PlayableInstance playable, final L2ItemInstance item)
  94. + {
  95. +
  96. +
  97. + if (!(playable instanceof L2PcInstance))
  98. + return;
  99. + final L2PcInstance activeChar = (L2PcInstance) playable;
  100. + if (activeChar.isInOlympiadMode())
  101. + {
  102. + activeChar.sendMessage("This Item Cannot Be Used On Olympiad Games.");
  103. + }
  104. + else if (!activeChar.isInsideZone(L2Character.ZONE_PEACE)){
  105. + activeChar.sendMessage("You can only use this item in peace zone..");
  106. + return;
  107. + }
  108. + activeChar.setClassChangeItemId(item.getItemId());
  109. + final NpcHtmlMessage html = new NpcHtmlMessage(0);
  110. + html.setFile("data/html/mods/class_changer/Warning.htm");
  111. + activeChar.sendPacket(html);
  112. + activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  113. + }
  114. +
  115. + @Override
  116. + public int[] getItemIds()
  117. + {
  118. + return ITEM_IDS;
  119. + }
  120. +}
  121. \ No newline at end of file
  122. diff --git a/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java
  123. index 223b046..eafa66d 100644
  124. --- a/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java
  125. +++ b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java
  126. @@ -19643,5 +19643,19 @@
  127.  
  128. _currentPetSkill = new SkillDat(currentSkill, ctrlPressed, shiftPressed);
  129. }
  130. +
  131. + //inicio classitem
  132. + private int _classChangeItemId = 0;
  133. +
  134. + public int getClassChangeItemId()
  135. + {
  136. + return _classChangeItemId;
  137. + }
  138. +
  139. + public void setClassChangeItemId(int itemId)
  140. + {
  141. + _classChangeItemId = itemId;
  142. + }
  143. + //fim class item
  144.  
  145. }
  146. \ No newline at end of file
  147. diff --git a/head-src/com/l2jfrozen/gameserver/model/entity/olympiad/Olympiad.java b/head-src/com/l2jfrozen/gameserver/model/entity/olympiad/Olympiad.java
  148. index 4e14ca8..75bea8c 100644
  149. --- a/head-src/com/l2jfrozen/gameserver/model/entity/olympiad/Olympiad.java
  150. +++ b/head-src/com/l2jfrozen/gameserver/model/entity/olympiad/Olympiad.java
  151. @@ -572,7 +572,7 @@
  152. return _nobles.size();
  153. }
  154.  
  155. - protected static StatsSet getNobleStats(final int playerId)
  156. + public static StatsSet getNobleStats(final int playerId)
  157. {
  158. return _nobles.get(playerId);
  159. }
  160. diff --git a/head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestBypassToServer.java b/head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestBypassToServer.java
  161. index 921c087..2f940ba 100644
  162. --- a/head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestBypassToServer.java
  163. +++ b/head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestBypassToServer.java
  164. @@ -20,6 +20,10 @@
  165. */
  166. package com.l2jfrozen.gameserver.network.clientpackets;
  167.  
  168. +import java.sql.Connection;
  169. +import java.sql.PreparedStatement;
  170. +import java.util.StringTokenizer;
  171. +
  172. import org.apache.log4j.Logger;
  173.  
  174. import com.l2jfrozen.Config;
  175. @@ -30,12 +34,14 @@
  176. import com.l2jfrozen.gameserver.handler.IAdminCommandHandler;
  177. import com.l2jfrozen.gameserver.handler.custom.CustomBypassHandler;
  178. import com.l2jfrozen.gameserver.model.L2Object;
  179. +import com.l2jfrozen.gameserver.model.L2Skill;
  180. import com.l2jfrozen.gameserver.model.L2World;
  181. import com.l2jfrozen.gameserver.model.actor.instance.L2ClassMasterInstance;
  182. import com.l2jfrozen.gameserver.model.actor.instance.L2NpcInstance;
  183. import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  184. import com.l2jfrozen.gameserver.model.actor.instance.L2SymbolMakerInstance;
  185. import com.l2jfrozen.gameserver.model.actor.position.L2CharPosition;
  186. +import com.l2jfrozen.gameserver.model.base.ClassId;
  187. import com.l2jfrozen.gameserver.model.entity.event.CTF;
  188. import com.l2jfrozen.gameserver.model.entity.event.DM;
  189. import com.l2jfrozen.gameserver.model.entity.event.L2Event;
  190. @@ -44,7 +50,10 @@
  191. import com.l2jfrozen.gameserver.model.entity.olympiad.Olympiad;
  192. import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
  193. import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
  194. +import com.l2jfrozen.gameserver.network.serverpackets.PlaySound;
  195. +import com.l2jfrozen.gameserver.templates.StatsSet;
  196. import com.l2jfrozen.gameserver.util.GMAudit;
  197. +import com.l2jfrozen.util.database.L2DatabaseFactory;
  198.  
  199. public final class RequestBypassToServer extends L2GameClientPacket
  200. {
  201. @@ -318,6 +327,40 @@
  202. {
  203. Olympiad.bypassChangeArena(_command, activeChar);
  204. }
  205. + else if (_command.startsWith("class_index"))
  206. + {
  207. + NpcHtmlMessage html = new NpcHtmlMessage(0);
  208. + html.setFile("data/html/mods/class_changer/Class.htm");
  209. + activeChar.sendPacket(html);
  210. + activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  211. + }
  212. + else if (_command.startsWith("classe_change"))
  213. + {
  214. + StringTokenizer st = new StringTokenizer(_command);
  215. + st.nextToken();
  216. + String type = null;
  217. + type = st.nextToken();
  218. + try
  219. + {
  220. + if (activeChar.getBaseClass() != activeChar.getClassId().getId())
  221. + {
  222. + activeChar.sendMessage("You need to be in your base class to be able to use this item.");
  223. + return ;
  224. + }
  225. + if (activeChar.getLevel() < 76)
  226. + {
  227. + activeChar.sendMessage("You need to be at least 76 level in order to use class card.");
  228. + return;
  229. + }
  230. + if (activeChar.isInOlympiadMode())
  231. + {
  232. + activeChar.sendMessage("This item cannot be used on olympiad games.");
  233. + return;
  234. + }
  235. + ClassChangeCoin(activeChar, type);
  236. + }
  237. + catch (StringIndexOutOfBoundsException e)
  238. + {
  239. + }
  240. + }
  241. }
  242. catch (final Exception e)
  243. {
  244. @@ -332,6 +375,842 @@
  245. // }
  246. }
  247.  
  248. + private static void ClassChangeCoin(L2PcInstance player, String command)
  249. + {
  250. + String nameclasse = player.getTemplate().getClassName();
  251. +
  252. + String type = command;
  253. + if (type.equals("---SELECT---"))
  254. + {
  255. + NpcHtmlMessage html = new NpcHtmlMessage(0);
  256. + html.setFile("data/html/mods/class_changer/Class.htm");
  257. + player.sendPacket(html);
  258. + player.sendPacket(ActionFailed.STATIC_PACKET);
  259. + }
  260. + if (type.equals("Duelist"))
  261. + {
  262. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  263. + {
  264. + if (player.getClassId().getId() == 88)
  265. + {
  266. + player.sendMessage("Your class is already " + nameclasse + ".");
  267. + return;
  268. + }
  269. +
  270. + RemoverSkills(player);
  271. +
  272. + player.setClassId(88);
  273. + if (!player.isSubClassActive())
  274. + player.setBaseClass(88);
  275. +
  276. + Finish(player);
  277. + }
  278. + else
  279. + {
  280. + player.sendMessage("You dont have class card item!");
  281. + return;
  282. + }
  283. + }
  284. + if (type.equals("DreadNought"))
  285. + {
  286. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  287. + {
  288. + if (player.getClassId().getId() == 89)
  289. + {
  290. + player.sendMessage("Your class is already "+nameclasse+".");
  291. + return;
  292. + }
  293. +
  294. + RemoverSkills(player);
  295. +
  296. + player.setClassId(89);
  297. + if (!player.isSubClassActive())
  298. + player.setBaseClass(89);
  299. + Finish(player);
  300. + }
  301. + else
  302. + {
  303. + player.sendMessage("You dont have class card item!");
  304. + return;
  305. + }
  306. + }
  307. + if (type.equals("Phoenix_Knight"))
  308. + {
  309. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  310. + {
  311. + if (player.getClassId().getId() == 90)
  312. + {
  313. + player.sendMessage("Your class is already "+nameclasse+".");
  314. + return;
  315. + }
  316. +
  317. + RemoverSkills(player);
  318. +
  319. + player.setClassId(90);
  320. + if (!player.isSubClassActive())
  321. + player.setBaseClass(90);
  322. + Finish(player);
  323. + }
  324. + else
  325. + {
  326. + player.sendMessage("You dont have class card item!");
  327. + return;
  328. + }
  329. + }
  330. + if (type.equals("Hell_Knight"))
  331. + {
  332. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  333. + {
  334. + if (player.getClassId().getId() == 91)
  335. + {
  336. + player.sendMessage("Your class is already "+nameclasse+".");
  337. + return;
  338. + }
  339. +
  340. + RemoverSkills(player);
  341. +
  342. + player.setClassId(91);
  343. + if (!player.isSubClassActive())
  344. + player.setBaseClass(91);
  345. + Finish(player);
  346. + }
  347. + else
  348. + {
  349. + player.sendMessage("You dont have class card item!");
  350. + return;
  351. + }
  352. + }
  353. + if (type.equals("Sagittarius"))
  354. + {
  355. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  356. + {
  357. + if (player.getClassId().getId() == 92)
  358. + {
  359. + player.sendMessage("Your class is already "+nameclasse+".");
  360. + return;
  361. + }
  362. +
  363. + RemoverSkills(player);
  364. +
  365. + player.setClassId(92);
  366. + if (!player.isSubClassActive())
  367. + player.setBaseClass(92);
  368. + Finish(player);
  369. + }
  370. + else
  371. + {
  372. + player.sendMessage("You dont have class card item!");
  373. + return;
  374. + }
  375. + }
  376. + if (type.equals("Adventurer"))
  377. + {
  378. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  379. + {
  380. + if (player.getClassId().getId() == 93)
  381. + {
  382. + player.sendMessage("Your class is already "+nameclasse+".");
  383. + return;
  384. + }
  385. +
  386. + RemoverSkills(player);
  387. +
  388. + player.setClassId(93);
  389. + if (!player.isSubClassActive())
  390. + player.setBaseClass(93);
  391. + Finish(player);
  392. + }
  393. + else
  394. + {
  395. + player.sendMessage("You dont have class card item!");
  396. + return;
  397. + }
  398. + }
  399. + if (type.equals("Archmage"))
  400. + {
  401. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  402. + {
  403. + if (player.getClassId().getId() == 94)
  404. + {
  405. + player.sendMessage("Your class is already "+nameclasse+".");
  406. + return;
  407. + }
  408. +
  409. + RemoverSkills(player);
  410. +
  411. + player.setClassId(94);
  412. + if (!player.isSubClassActive())
  413. + player.setBaseClass(94);
  414. + Finish(player);
  415. + }
  416. + else
  417. + {
  418. + player.sendMessage("You dont have class card item!");
  419. + return;
  420. + }
  421. + }
  422. + if (type.equals("Soultaker"))
  423. + {
  424. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  425. + {
  426. + if (player.getClassId().getId() == 95)
  427. + {
  428. + player.sendMessage("Your class is already "+nameclasse+".");
  429. + return;
  430. + }
  431. +
  432. + RemoverSkills(player);
  433. +
  434. + player.setClassId(95);
  435. + if (!player.isSubClassActive())
  436. + player.setBaseClass(95);
  437. + Finish(player);
  438. + }
  439. + else
  440. + {
  441. + player.sendMessage("You dont have class card item!");
  442. + return;
  443. + }
  444. + }
  445. + if (type.equals("Arcana_Lord"))
  446. + {
  447. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  448. + {
  449. + if (player.getClassId().getId() == 96)
  450. + {
  451. + player.sendMessage("Your class is already "+nameclasse+".");
  452. + return;
  453. + }
  454. +
  455. + RemoverSkills(player);
  456. +
  457. + player.setClassId(96);
  458. + if (!player.isSubClassActive())
  459. + player.setBaseClass(96);
  460. + Finish(player);
  461. + }
  462. + else
  463. + {
  464. + player.sendMessage("You dont have class card item!");
  465. + return;
  466. + }
  467. + }
  468. + if (type.equals("Cardinal"))
  469. + {
  470. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  471. + {
  472. + if (player.getClassId().getId() == 97)
  473. + {
  474. + player.sendMessage("Your class is already "+nameclasse+".");
  475. + return;
  476. + }
  477. +
  478. + RemoverSkills(player);
  479. +
  480. + player.setClassId(97);
  481. + if (!player.isSubClassActive())
  482. + player.setBaseClass(97);
  483. + Finish(player);
  484. + }
  485. + else
  486. + {
  487. + player.sendMessage("You dont have class card item!");
  488. + return;
  489. + }
  490. + }
  491. + if (type.equals("Hierophant"))
  492. + {
  493. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  494. + {
  495. + if (player.getClassId().getId() == 98)
  496. + {
  497. + player.sendMessage("Your class is already "+nameclasse+".");
  498. + return;
  499. + }
  500. +
  501. + RemoverSkills(player);
  502. +
  503. + player.setClassId(98);
  504. + if (!player.isSubClassActive())
  505. + player.setBaseClass(98);
  506. + Finish(player);
  507. + }
  508. + else
  509. + {
  510. + player.sendMessage("You dont have class card item!");
  511. + return;
  512. + }
  513. + }
  514. + if (type.equals("Eva_Templar"))
  515. + {
  516. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  517. + {
  518. + if (player.getClassId().getId() == 99)
  519. + {
  520. + player.sendMessage("Your class is already "+nameclasse+".");
  521. + return;
  522. + }
  523. +
  524. + RemoverSkills(player);
  525. +
  526. + player.setClassId(99);
  527. + if (!player.isSubClassActive())
  528. + player.setBaseClass(99);
  529. + Finish(player);
  530. + }
  531. + else
  532. + {
  533. + player.sendMessage("You dont have class card item!");
  534. + return;
  535. + }
  536. + }
  537. + if (type.equals("Sword_Muse"))
  538. + {
  539. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  540. + {
  541. + if (player.getClassId().getId() == 100)
  542. + {
  543. + player.sendMessage("Your class is already "+nameclasse+".");
  544. + return;
  545. + }
  546. +
  547. + RemoverSkills(player);
  548. +
  549. + player.setClassId(100);
  550. + if (!player.isSubClassActive())
  551. + player.setBaseClass(100);
  552. + Finish(player);
  553. + }
  554. + else
  555. + {
  556. + player.sendMessage("You dont have class card item!");
  557. + return;
  558. + }
  559. + }
  560. + if (type.equals("Wind_Rider"))
  561. + {
  562. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  563. + {
  564. + if (player.getClassId().getId() == 101)
  565. + {
  566. + player.sendMessage("Your class is already "+nameclasse+".");
  567. + return;
  568. + }
  569. +
  570. + RemoverSkills(player);
  571. +
  572. + player.setClassId(101);
  573. + if (!player.isSubClassActive())
  574. + player.setBaseClass(101);
  575. + Finish(player);
  576. + }
  577. + else
  578. + {
  579. + player.sendMessage("You dont have class card item!");
  580. + return;
  581. + }
  582. + }
  583. + if (type.equals("Moonli_Sentinel"))
  584. + {
  585. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  586. + {
  587. + if (player.getClassId().getId() == 102)
  588. + {
  589. + player.sendMessage("Your class is already "+nameclasse+".");
  590. + return;
  591. + }
  592. +
  593. + RemoverSkills(player);
  594. +
  595. + player.setClassId(102);
  596. + if (!player.isSubClassActive())
  597. + player.setBaseClass(102);
  598. + Finish(player);
  599. + }
  600. + else
  601. + {
  602. + player.sendMessage("You dont have class card item!");
  603. + return;
  604. + }
  605. + }
  606. + if (type.equals("Mystic_Muse"))
  607. + {
  608. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  609. + {
  610. + if (player.getClassId().getId() == 103)
  611. + {
  612. + player.sendMessage("Your class is already "+nameclasse+".");
  613. + return;
  614. + }
  615. +
  616. + RemoverSkills(player);
  617. +
  618. + player.setClassId(103);
  619. + if (!player.isSubClassActive())
  620. + player.setBaseClass(103);
  621. + Finish(player);
  622. + }
  623. + else
  624. + {
  625. + player.sendMessage("You dont have class card item!");
  626. + return;
  627. + }
  628. + }
  629. + if (type.equals("Elemental_Master"))
  630. + {
  631. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  632. + {
  633. + if (player.getClassId().getId() == 104)
  634. + {
  635. + player.sendMessage("Your class is already "+nameclasse+".");
  636. + return;
  637. + }
  638. +
  639. + RemoverSkills(player);
  640. +
  641. + player.setClassId(104);
  642. + if (!player.isSubClassActive())
  643. + player.setBaseClass(104);
  644. + Finish(player);
  645. + }
  646. + else
  647. + {
  648. + player.sendMessage("You dont have class card item!");
  649. + return;
  650. + }
  651. + }
  652. + if (type.equals("Eva_Saint"))
  653. + {
  654. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  655. + {
  656. + if (player.getClassId().getId() == 105)
  657. + {
  658. + player.sendMessage("Your class is already "+nameclasse+".");
  659. + return;
  660. + }
  661. +
  662. + RemoverSkills(player);
  663. +
  664. + player.setClassId(105);
  665. + if (!player.isSubClassActive())
  666. + player.setBaseClass(105);
  667. + Finish(player);
  668. + }
  669. + else
  670. + {
  671. + player.sendMessage("You dont have class card item!");
  672. + return;
  673. + }
  674. + }
  675. + if (type.equals("Shillien_Templar"))
  676. + {
  677. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  678. + {
  679. + if (player.getClassId().getId() == 106)
  680. + {
  681. + player.sendMessage("Your class is already "+nameclasse+".");
  682. + return;
  683. + }
  684. +
  685. + RemoverSkills(player);
  686. +
  687. + player.setClassId(106);
  688. + if (!player.isSubClassActive())
  689. + player.setBaseClass(106);
  690. + Finish(player);
  691. + }
  692. + else
  693. + {
  694. + player.sendMessage("You dont have class card item!");
  695. + return;
  696. + }
  697. + }
  698. + if (type.equals("Spectral_Dancer"))
  699. + {
  700. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  701. + {
  702. + if (player.getClassId().getId() == 107)
  703. + {
  704. + player.sendMessage("Your class is already "+nameclasse+".");
  705. + return;
  706. + }
  707. +
  708. + RemoverSkills(player);
  709. +
  710. + player.setClassId(107);
  711. + if (!player.isSubClassActive())
  712. + player.setBaseClass(107);
  713. + Finish(player);
  714. + }
  715. + else
  716. + {
  717. + player.sendMessage("You dont have class card item!");
  718. + return;
  719. + }
  720. + }
  721. + if (type.equals("Ghost_Hunter"))
  722. + {
  723. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  724. + {
  725. + if (player.getClassId().getId() == 108)
  726. + {
  727. + player.sendMessage("Your class is already "+nameclasse+".");
  728. + return;
  729. + }
  730. +
  731. + RemoverSkills(player);
  732. +
  733. + player.setClassId(108);
  734. + if (!player.isSubClassActive())
  735. + player.setBaseClass(108);
  736. + Finish(player);
  737. + }
  738. + else
  739. + {
  740. + player.sendMessage("You dont have class card item!");
  741. + return;
  742. + }
  743. + }
  744. + if (type.equals("Ghost_Sentinel"))
  745. + {
  746. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  747. + {
  748. + if (player.getClassId().getId() == 109)
  749. + {
  750. + player.sendMessage("Your class is already "+nameclasse+".");
  751. + return;
  752. + }
  753. +
  754. + RemoverSkills(player);
  755. +
  756. + player.setClassId(109);
  757. + if (!player.isSubClassActive())
  758. + player.setBaseClass(109);
  759. + Finish(player);
  760. + }
  761. + else
  762. + {
  763. + player.sendMessage("You dont have class card item!");
  764. + return;
  765. + }
  766. + }
  767. + if (type.equals("Storm_Screamer"))
  768. + {
  769. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  770. + {
  771. + if (player.getClassId().getId() == 110)
  772. + {
  773. + player.sendMessage("Your class is already "+nameclasse+".");
  774. + return;
  775. + }
  776. +
  777. + RemoverSkills(player);
  778. +
  779. + player.setClassId(110);
  780. + if (!player.isSubClassActive())
  781. + player.setBaseClass(110);
  782. + Finish(player);
  783. + }
  784. + else
  785. + {
  786. + player.sendMessage("You dont have class card item!");
  787. + return;
  788. + }
  789. + }
  790. + if (type.equals("Spectral_Master"))
  791. + {
  792. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  793. + {
  794. + if (player.getClassId().getId() == 111)
  795. + {
  796. + player.sendMessage("Your class is already "+nameclasse+".");
  797. + return;
  798. + }
  799. +
  800. + RemoverSkills(player);
  801. +
  802. + player.setClassId(111);
  803. + if (!player.isSubClassActive())
  804. + player.setBaseClass(111);
  805. + Finish(player);
  806. + }
  807. + else
  808. + {
  809. + player.sendMessage("You dont have class card item!");
  810. + return;
  811. + }
  812. + }
  813. + if (type.equals("Shillen_Saint"))
  814. + {
  815. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  816. + {
  817. + if (player.getClassId().getId() == 112)
  818. + {
  819. + player.sendMessage("Your class is already "+nameclasse+".");
  820. + return;
  821. + }
  822. +
  823. + RemoverSkills(player);
  824. +
  825. + player.setClassId(112);
  826. + if (!player.isSubClassActive())
  827. + player.setBaseClass(112);
  828. + Finish(player);
  829. + }
  830. + else
  831. + {
  832. + player.sendMessage("You dont have class card item!");
  833. + return;
  834. + }
  835. + }
  836. + if (type.equals("Titan"))
  837. + {
  838. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  839. + {
  840. + if (player.getClassId().getId() == 113)
  841. + {
  842. + player.sendMessage("Your class is already "+nameclasse+".");
  843. + return;
  844. + }
  845. +
  846. + RemoverSkills(player);
  847. +
  848. + player.setClassId(113);
  849. + if (!player.isSubClassActive())
  850. + player.setBaseClass(113);
  851. + Finish(player);
  852. + }
  853. + else
  854. + {
  855. + player.sendMessage("You dont have class card item!");
  856. + return;
  857. + }
  858. + }
  859. + if (type.equals("Grand_Khauatari"))
  860. + {
  861. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  862. + {
  863. + if (player.getClassId().getId() == 114)
  864. + {
  865. + player.sendMessage("Your class is already "+nameclasse+".");
  866. + return;
  867. + }
  868. +
  869. + RemoverSkills(player);
  870. +
  871. + player.setClassId(114);
  872. + if (!player.isSubClassActive())
  873. + player.setBaseClass(114);
  874. + Finish(player);
  875. + }
  876. + else
  877. + {
  878. + player.sendMessage("You dont have class card item!");
  879. + return;
  880. + }
  881. + }
  882. + if (type.equals("Dominator"))
  883. + {
  884. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  885. + {
  886. + if (player.getClassId().getId() == 115)
  887. + {
  888. + player.sendMessage("Your class is already "+nameclasse+".");
  889. + return;
  890. + }
  891. +
  892. + RemoverSkills(player);
  893. +
  894. + player.setClassId(115);
  895. + if (!player.isSubClassActive())
  896. + player.setBaseClass(115);
  897. + Finish(player);
  898. + }
  899. + else
  900. + {
  901. + player.sendMessage("You dont have class card item!");
  902. + return;
  903. + }
  904. + }
  905. + if (type.equals("Doomcryer"))
  906. + {
  907. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  908. + {
  909. + if (player.getClassId().getId() == 116)
  910. + {
  911. + player.sendMessage("Your class is already "+nameclasse+".");
  912. + return;
  913. + }
  914. +
  915. + RemoverSkills(player);
  916. +
  917. + player.setClassId(116);
  918. + if (!player.isSubClassActive())
  919. + player.setBaseClass(116);
  920. + Finish(player);
  921. + }
  922. + else
  923. + {
  924. + player.sendMessage("You dont have class card item!");
  925. + return;
  926. + }
  927. + }
  928. + if (type.equals("Fortune_Seeker"))
  929. + {
  930. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  931. + {
  932. + if (player.getClassId().getId() == 117)
  933. + {
  934. + player.sendMessage("Your class is already "+nameclasse+".");
  935. + return;
  936. + }
  937. +
  938. + RemoverSkills(player);
  939. +
  940. + player.setClassId(117);
  941. + if (!player.isSubClassActive())
  942. + player.setBaseClass(117);
  943. + Finish(player);
  944. + }
  945. + else
  946. + {
  947. + player.sendMessage("You dont have class card item!");
  948. + return;
  949. + }
  950. + }
  951. + if (type.equals("Maestro"))
  952. + {
  953. + if (player.getInventory().getInventoryItemCount(Config.ITEM_CLASS_ID, 0) >= 1)
  954. + {
  955. + if (player.getClassId().getId() == 118)
  956. + {
  957. + player.sendMessage("Your class is already "+nameclasse+".");
  958. + return;
  959. + }
  960. +
  961. + RemoverSkills(player);
  962. +
  963. + player.setClassId(118);
  964. + if (!player.isSubClassActive())
  965. + player.setBaseClass(118);
  966. + Finish(player);
  967. + }
  968. + else
  969. + {
  970. + player.sendMessage("You dont have class card item!");
  971. + return;
  972. + }
  973. + }
  974. + }
  975. + private static void Finish(L2PcInstance activeChar)
  976. + {
  977. + String newclass = activeChar.getTemplate().getClassName();
  978. +
  979. + DeleteHenna(activeChar, 0);
  980. +
  981. + activeChar.sendMessage(activeChar.getName() + " is now a " + newclass + ".");
  982. + activeChar.refreshOverloaded();
  983. + activeChar.store();
  984. + activeChar.broadcastUserInfo();
  985. + activeChar.sendSkillList();
  986. + activeChar.sendPacket(new PlaySound("ItemSound.quest_finish"));
  987. +
  988. + if (activeChar.isNoble())
  989. + {
  990. + StatsSet playerStat = Olympiad.getNobleStats(activeChar.getObjectId());
  991. + if (!(playerStat == null))
  992. + {
  993. + updateClasse(activeChar);
  994. + DeleteHero(activeChar);
  995. + activeChar.sendMessage("You now has " + Olympiad.getInstance().getNoblePoints(activeChar.getObjectId()) + " Olympiad points.");
  996. + }
  997. + }
  998. + activeChar.sendMessage("You will be disconnected for security reasons.");
  999. + waitSecs(5);
  1000. +
  1001. + activeChar.getClient().closeNow();
  1002. + }
  1003. + public static void DeleteHenna(L2PcInstance player, int classIndex)
  1004. + {
  1005. + try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  1006. + {
  1007. + // Remove all henna info stored for this sub-class.
  1008. + PreparedStatement statement = con.prepareStatement(DELETE_CHAR_HENNAS);
  1009. + statement.setInt(1, player.getObjectId());
  1010. + statement.setInt(2, classIndex);
  1011. + statement.execute();
  1012. + statement.close();
  1013. + con.close();
  1014. + }
  1015. + catch (Exception e)
  1016. + {
  1017. + LOGGER.warn("could not clear char Hero: " + e);
  1018. + }
  1019. + }
  1020. +
  1021. + public static void DeleteHero(L2PcInstance player)
  1022. + {
  1023. + try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  1024. + {
  1025. + PreparedStatement statement = con.prepareStatement(DELETE_CHAR_HERO);
  1026. + statement.setInt(1, player.getObjectId());
  1027. + statement.execute();
  1028. + statement.close();
  1029. + con.close();
  1030. + }
  1031. + catch (Exception e)
  1032. + {
  1033. + LOGGER.warn("could not clear char Hero: " + e);
  1034. + }
  1035. + }
  1036. + private static void RemoverSkills(L2PcInstance activeChar)
  1037. + {
  1038. + L2Skill[] skills = activeChar.getAllSkills();
  1039. +
  1040. + for (L2Skill skill : skills)
  1041. + activeChar.removeSkill(skill);
  1042. +
  1043. + activeChar.destroyItemByItemId("Classe Change", activeChar.getClassChangeItemId(), 1, null, true);
  1044. + }
  1045. + // Updates That Will be Executed by MySQL
  1046. + // ----------------------------------------
  1047. + static String INSERT_DATA = "REPLACE INTO olympiad_nobles (char_id, class_id, olympiad_points) VALUES (?,?,?)";
  1048. + static String OLYMPIAD_UPDATE = "UPDATE olympiad_nobles SET class_id=?, olympiad_points=?, competitions_done=?, competitions_won=?, competitions_lost=?, competitions_drawn=? WHERE char_Id=?";
  1049. + static String DELETE_CHAR_HERO = "DELETE FROM heroes WHERE char_id=?";
  1050. + static String DELETE_CHAR_HENNAS = "DELETE FROM character_hennas WHERE char_obj_id=? AND class_index=?";
  1051. +
  1052. + public static void waitSecs(int i)
  1053. + {
  1054. + try
  1055. + {
  1056. + Thread.sleep(i * 1000);
  1057. + }
  1058. + catch (InterruptedException e)
  1059. + {
  1060. + e.printStackTrace();
  1061. + }
  1062. + }
  1063. + public static void updateClasse(L2PcInstance player)
  1064. + {
  1065. + if (player == null)
  1066. + return;
  1067. +
  1068. + try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  1069. + {
  1070. + PreparedStatement stmt = con.prepareStatement(INSERT_DATA);
  1071. +
  1072. + stmt.setInt(1, player.getObjectId());
  1073. + stmt.setInt(2, player.getClassId().getId());
  1074. + stmt.setInt(3, 18);
  1075. + stmt.execute();
  1076. + stmt.close();
  1077. + con.close();
  1078. + }
  1079. + catch (Exception e)
  1080. + {
  1081. + LOGGER.warn("Class Card: Could not clear char Olympiad Points: " + e);
  1082. + }
  1083. + }
  1084. /**
  1085. * @param activeChar
  1086. */
  1087. diff --git a/head-src/com/l2jfrozen/gameserver/templates/L2PcTemplate.java b/head-src/com/l2jfrozen/gameserver/templates/L2PcTemplate.java
  1088. index 1f4bb2d..a5f4b7c 100644
  1089. --- a/head-src/com/l2jfrozen/gameserver/templates/L2PcTemplate.java
  1090. +++ b/head-src/com/l2jfrozen/gameserver/templates/L2PcTemplate.java
  1091. @@ -138,4 +138,9 @@
  1092. {
  1093. return 333; // TODO: unhardcode it
  1094. }
  1095. +
  1096. + public String getClassName()
  1097. + {
  1098. + return className;
  1099. + }
  1100. }
  1101.  
Add Comment
Please, Sign In to add comment