Sarada-L2

ResetClass Frozen Teste 1

Jun 21st, 2021
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.67 KB | None | 0 0
  1. +package com.l2jfrozen.gameserver.model.actor.instance;
  2. +
  3. +import java.sql.Connection;
  4. +import java.sql.PreparedStatement;
  5. +
  6. +import com.l2jfrozen.gameserver.cache.HtmCache;
  7. +import com.l2jfrozen.gameserver.model.L2Skill;
  8. +import com.l2jfrozen.gameserver.model.entity.olympiad.Olympiad;
  9. +import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
  10. +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
  11. +import com.l2jfrozen.gameserver.network.serverpackets.PlaySound;
  12. +import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
  13. +import com.l2jfrozen.gameserver.templates.StatsSet;
  14. +import com.l2jfrozen.util.database.L2DatabaseFactory;
  15. +
  16. +public class L2ResetClassInstance extends L2NpcInstance
  17. +{
  18. + public L2ResetClassInstance(int objectId, L2NpcTemplate template)
  19. + {
  20. + super(objectId, template);
  21. + }
  22. +
  23. + @Override
  24. + public void showChatWindow(L2PcInstance playerInstance, int val)
  25. + {
  26. + if (playerInstance == null)
  27. + return;
  28. +
  29. + String htmContent = HtmCache.getInstance().getHtm("data/html/ResetClass/ResetClass.htm");
  30. + if (val > 0)
  31. + {
  32. + htmContent = HtmCache.getInstance().getHtm("data/html/ResetClass/ResetClass-" + val + ".htm");
  33. + }
  34. + if (htmContent != null)
  35. + {
  36. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId());
  37. +
  38. + npcHtmlMessage.setHtml(htmContent);
  39. + npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId()));
  40. + playerInstance.sendPacket(npcHtmlMessage);
  41. + }
  42. + playerInstance.sendPacket(ActionFailed.STATIC_PACKET);
  43. + }
  44. +
  45. + @Override
  46. + public void onBypassFeedback(L2PcInstance player, String command)
  47. + {
  48. + if ((player.getLevel() < 76) && (player.getLevel() <= 80))
  49. + {
  50. + player.sendMessage("Usted No tiene El LvL Necesario.");
  51. + return;
  52. + }
  53. + if (!(player.getClassId().level() == 3))
  54. + {
  55. + player.sendMessage("Necesitas la tercera Class.");
  56. + return;
  57. + }
  58. + if (!(player.getInventory().getInventoryItemCount(57, 0) >= 10))
  59. + {
  60. + player.sendMessage("No tienes 3 Subs.");
  61. + return;
  62. + }
  63. + if (player.isAio())
  64. + {
  65. + player.sendMessage("You may not add a new subclass.");
  66. + return;
  67. + }
  68. + if (command.startsWith("HumanoF1"))
  69. + {
  70. + player.setClassId(0);
  71. + player.setBaseClass(0);
  72. + Finish(player);
  73. + return;
  74. + }
  75. + if (command.startsWith("HumanoM1"))
  76. + {
  77. + player.setClassId(10);
  78. + player.setBaseClass(10);
  79. + Finish(player);
  80. + return;
  81. + }
  82. + if (command.startsWith("ElfoBF1"))
  83. + {
  84. + player.setClassId(18);
  85. + player.setBaseClass(18);
  86. + Finish(player);
  87. + return;
  88. + }
  89. + if (command.startsWith("ElfoBM1"))
  90. + {
  91. + player.setClassId(25);
  92. + player.setBaseClass(25);
  93. +
  94. + Finish(player);
  95. + return;
  96. + }
  97. + if (command.startsWith("ElfoNF1"))
  98. + {
  99. + player.setClassId(31);
  100. + player.setBaseClass(31);
  101. + Finish(player);
  102. + return;
  103. + }
  104. + if (command.startsWith("ElfoNM1"))
  105. + {
  106. + player.setClassId(38);
  107. + player.setBaseClass(38);
  108. + Finish(player);
  109. + return;
  110. + }
  111. + if (command.startsWith("OrcF1"))
  112. + {
  113. + player.setClassId(44);
  114. + player.setBaseClass(44);
  115. + Finish(player);
  116. + return;
  117. + }
  118. + if (command.startsWith("OrcoM1"))
  119. + {
  120. + player.setClassId(49);
  121. + player.setBaseClass(49);
  122. + Finish(player);
  123. + return;
  124. + }
  125. + if (command.startsWith("Enano1"))
  126. + {
  127. + player.setClassId(53);
  128. + player.setBaseClass(53);
  129. + Finish(player);
  130. + return;
  131. + }
  132. + super.onBypassFeedback(player, command);
  133. + }
  134. + static String INSERT_DATA = "REPLACE INTO olympiad_nobles (char_id, class_id, olympiad_points) VALUES (?,?,?)";
  135. + static String OLYMPIAD_UPDATE = "UPDATE olympiad_nobles SET class_id=?, olympiad_points=?, competitions_done=?, competitions_won=?, competitions_lost=?, competitions_drawn=? WHERE char_Id=?";
  136. + static String DELETE_CHAR_HERO = "DELETE FROM heroes WHERE char_id=?";
  137. + static String DELETE_CHAR_HENNAS = "DELETE FROM character_hennas WHERE char_obj_id=? AND class_index=?";
  138. + static String DELETE_CHAR_SUBCLASS = "DELETE FROM character_subclasses WHERE char_obj_id=?";
  139. + public static void DeleteHero(L2PcInstance player)
  140. + {
  141. + try (Connection con = L2DatabaseFactory.getInstance().getConnection(false))
  142. + {
  143. + PreparedStatement statement = con.prepareStatement(DELETE_CHAR_HERO);
  144. + statement.setInt(1, player.getObjectId());
  145. + statement.execute();
  146. + statement.close();
  147. + con.close();
  148. + }
  149. + catch (Exception e)
  150. + {
  151. + LOGGER.warn("could not clear char Hero: " + e);
  152. + }
  153. + }
  154. + public static void DeleteSubClasses(L2PcInstance player)
  155. + {
  156. + try (Connection con = L2DatabaseFactory.getInstance().getConnection(false))
  157. + {
  158. + PreparedStatement statement = con.prepareStatement(DELETE_CHAR_SUBCLASS);
  159. + statement.setInt(1, player.getObjectId());
  160. + statement.execute();
  161. + statement.close();
  162. + con.close();
  163. + }
  164. + catch (Exception e)
  165. + {
  166. + LOGGER.warn("could not clear char Subclasses: " + e);
  167. + }
  168. + }
  169. + public static void updateClasse(L2PcInstance player)
  170. + {
  171. + if (player == null)
  172. + return;
  173. +
  174. + try (Connection con = L2DatabaseFactory.getInstance().getConnection(false))
  175. + {
  176. + PreparedStatement stmt = con.prepareStatement(INSERT_DATA);
  177. +
  178. + stmt.setInt(1, player.getObjectId());
  179. + stmt.setInt(2, player.getClassId().getId());
  180. + stmt.setInt(3, 18);
  181. + stmt.execute();
  182. + stmt.close();
  183. + con.close();
  184. + }
  185. + catch (Exception e)
  186. + {
  187. + LOGGER.warn("Class Card: Could not clear char Olympiad Points: " + e);
  188. + }
  189. + }
  190. + private static void Finish(L2PcInstance activeChar)
  191. + {
  192. + String newclass = activeChar.getTemplate().getClassName();
  193. + for (final L2Skill skill : activeChar.getAllSkills())
  194. + {
  195. + activeChar.removeSkill(skill);
  196. + }
  197. + DeleteHenna(activeChar, 0);
  198. + DeleteSubClasses(activeChar);
  199. + activeChar.sendMessage(activeChar.getName() + " is now a " + newclass + ".");
  200. + activeChar.refreshOverloaded();
  201. + activeChar.store();
  202. + activeChar.broadcastUserInfo();
  203. + activeChar.sendSkillList();
  204. + activeChar.sendPacket(new PlaySound("ItemSound.quest_finish"));
  205. +
  206. + if (activeChar.isNoble())
  207. + {
  208. + StatsSet playerStat = Olympiad.getNobleStats(activeChar.getObjectId());
  209. + if (!(playerStat == null))
  210. + {
  211. + updateClasse(activeChar);
  212. + DeleteHero(activeChar);
  213. + activeChar.sendMessage("You now has " + Olympiad.getInstance().getNoblePoints(activeChar.getObjectId()) + " Olympiad points.");
  214. + }
  215. + }
  216. + activeChar.sendMessage("You will be disconnected for security reasons.");
  217. + waitSecs(5);
  218. +
  219. + activeChar.getClient().closeNow();
  220. + }
  221. + public static void waitSecs(int i)
  222. + {
  223. + try
  224. + {
  225. + Thread.sleep(i * 1000);
  226. + }
  227. + catch (InterruptedException e)
  228. + {
  229. + e.printStackTrace();
  230. + }
  231. + }
  232. + public static void DeleteHenna(L2PcInstance player, int classIndex)
  233. + {
  234. + try (Connection con = L2DatabaseFactory.getInstance().getConnection(false))
  235. + {
  236. + // Remove all henna info stored for this sub-class.
  237. + PreparedStatement statement = con.prepareStatement(DELETE_CHAR_HENNAS);
  238. + statement.setInt(1, player.getObjectId());
  239. + statement.setInt(2, classIndex);
  240. + statement.execute();
  241. + statement.close();
  242. + con.close();
  243. + }
  244. + catch (Exception e)
  245. + {
  246. + LOGGER.warn("could not clear Hennas Dyes: " + e);
  247. + }
  248. + }
  249. +}
  250.  
  251. HTML ResetClass.html
  252.  
  253. +<html>
  254. +<body>
  255. +<center>
  256. +<font color="0099FF">ResetClass Master</font><br><br>
  257. +</center>
  258. +<center>
  259. +<font color="AAAAAA">Hola, Yo puedo ayudarte a Resetear tus SubClass!</font><br>
  260. +</center>
  261. +<font color="AAAAAA">Los Unicos Requisitos son los Siguientes: Tener todas las SubClass & Tercera Profesion!</font><br>
  262. +<center>
  263. +<br><br><a action="bypass -h npc_%objectId%_Chat 1"><font color="00AA00">De Acuerdo</font></a><br><br>
  264. +<br><br><br><br>
  265. +<center><img src="l2font-e.replay_logo-e" width=255 height=60></center>
  266. +<br><br><br><br><br><br><br>
  267. +<font color="00AA00">Lineage Brothers</font>
  268. +</center>
  269. +</body>
  270. +</html>
  271.  
  272. HTML ResetClass-1.html
  273.  
  274. +<html>
  275. +<body>
  276. +<center>
  277. +<font color="FF9933">Humanos</font>
  278. +<img src="L2UI.SquareWhite" width=260 height=1>
  279. +</center>
  280. +<table width=260><tr><td width=65></td><td width=195>
  281. +> <a action="bypass -h npc_%objectId%_HumanoF1">Human Fighter</a><br>
  282. +> <a action="bypass -h npc_%objectId%_HumanoM1">Human Mage</a>
  283. +</td></tr></table>
  284. +<center>
  285. +<img src="L2UI.SquareWhite" width=260 height=1>
  286. +<font color="FF9933">Elfos Blancos</font>
  287. +<img src="L2UI.SquareWhite" width=260 height=1>
  288. +</center>
  289. +<table width=260><tr><td width=65></td><td width=195>
  290. +> <a action="bypass -h npc_%objectId%_ElfoBF1">Elf Fighter</a><br>
  291. +> <a action="bypass -h npc_%objectId%_ElfoBM1">Elf Mage</a>
  292. +</td></tr></table>
  293. +<center>
  294. +<img src="L2UI.SquareWhite" width=260 height=1>
  295. +<font color="FF9933">Elfos Negros</font>
  296. +<img src="L2UI.SquareWhite" width=260 height=1>
  297. +</center>
  298. +<table width=260><tr><td width=65></td><td width=195>
  299. +> <a action="bypass -h npc_%objectId%_ElfoNF1">Dark Elf Fighter</a><br>
  300. +> <a action="bypass -h npc_%objectId%_ElfoNM1">Dark Elf Mage</a>
  301. +</td></tr></table>
  302. +<center>
  303. +<img src="L2UI.SquareWhite" width=260 height=1>
  304. +<font color="FF9933">Orcos</font>
  305. +<img src="L2UI.SquareWhite" width=260 height=1>
  306. +</center>
  307. +<table width=260><tr><td width=65></td><td width=195>
  308. +> <a action="bypass -h npc_%objectId%_OrcF1">Orc Fighter</a><br>
  309. +> <a action="bypass -h npc_%objectId%_OrcoM1">Orc Mage</a>
  310. +</td></tr></table>
  311. +<center>
  312. +<img src="L2UI.SquareWhite" width=260 height=1>
  313. +<font color="FF9933">Enanos</font>
  314. +<img src="L2UI.SquareWhite" width=260 height=1>
  315. +</center>
  316. +<table width=260><tr><td width=65></td><td width=195>
  317. +> <a action="bypass -h npc_%objectId%_Enano1">Dwarven Fighter</a><br>
  318. +</td></tr></table>
  319. +<img src="L2UI.SquareWhite" width=260 height=1><br>
  320. +</body>
  321. +</html>
Add Comment
Please, Sign In to add comment