Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- +package com.l2jfrozen.gameserver.model.actor.instance;
- +
- +import java.sql.Connection;
- +import java.sql.PreparedStatement;
- +
- +import com.l2jfrozen.gameserver.cache.HtmCache;
- +import com.l2jfrozen.gameserver.model.L2Skill;
- +import com.l2jfrozen.gameserver.model.entity.olympiad.Olympiad;
- +import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
- +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
- +import com.l2jfrozen.gameserver.network.serverpackets.PlaySound;
- +import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
- +import com.l2jfrozen.gameserver.templates.StatsSet;
- +import com.l2jfrozen.util.database.L2DatabaseFactory;
- +
- +public class L2ResetClassInstance extends L2NpcInstance
- +{
- + public L2ResetClassInstance(int objectId, L2NpcTemplate template)
- + {
- + super(objectId, template);
- + }
- +
- + @Override
- + public void showChatWindow(L2PcInstance playerInstance, int val)
- + {
- + if (playerInstance == null)
- + return;
- +
- + String htmContent = HtmCache.getInstance().getHtm("data/html/ResetClass/ResetClass.htm");
- + if (val > 0)
- + {
- + htmContent = HtmCache.getInstance().getHtm("data/html/ResetClass/ResetClass-" + val + ".htm");
- + }
- + if (htmContent != null)
- + {
- + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId());
- +
- + npcHtmlMessage.setHtml(htmContent);
- + npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId()));
- + playerInstance.sendPacket(npcHtmlMessage);
- + }
- + playerInstance.sendPacket(ActionFailed.STATIC_PACKET);
- + }
- +
- + @Override
- + public void onBypassFeedback(L2PcInstance player, String command)
- + {
- + if ((player.getLevel() < 76) && (player.getLevel() <= 80))
- + {
- + player.sendMessage("Usted No tiene El LvL Necesario.");
- + return;
- + }
- + if (!(player.getClassId().level() == 3))
- + {
- + player.sendMessage("Necesitas la tercera Class.");
- + return;
- + }
- + if (!(player.getInventory().getInventoryItemCount(57, 0) >= 10))
- + {
- + player.sendMessage("No tienes 3 Subs.");
- + return;
- + }
- + if (player.isAio())
- + {
- + player.sendMessage("You may not add a new subclass.");
- + return;
- + }
- + if (command.startsWith("HumanoF1"))
- + {
- + player.setClassId(0);
- + player.setBaseClass(0);
- + Finish(player);
- + return;
- + }
- + if (command.startsWith("HumanoM1"))
- + {
- + player.setClassId(10);
- + player.setBaseClass(10);
- + Finish(player);
- + return;
- + }
- + if (command.startsWith("ElfoBF1"))
- + {
- + player.setClassId(18);
- + player.setBaseClass(18);
- + Finish(player);
- + return;
- + }
- + if (command.startsWith("ElfoBM1"))
- + {
- + player.setClassId(25);
- + player.setBaseClass(25);
- +
- + Finish(player);
- + return;
- + }
- + if (command.startsWith("ElfoNF1"))
- + {
- + player.setClassId(31);
- + player.setBaseClass(31);
- + Finish(player);
- + return;
- + }
- + if (command.startsWith("ElfoNM1"))
- + {
- + player.setClassId(38);
- + player.setBaseClass(38);
- + Finish(player);
- + return;
- + }
- + if (command.startsWith("OrcF1"))
- + {
- + player.setClassId(44);
- + player.setBaseClass(44);
- + Finish(player);
- + return;
- + }
- + if (command.startsWith("OrcoM1"))
- + {
- + player.setClassId(49);
- + player.setBaseClass(49);
- + Finish(player);
- + return;
- + }
- + if (command.startsWith("Enano1"))
- + {
- + player.setClassId(53);
- + player.setBaseClass(53);
- + Finish(player);
- + return;
- + }
- + super.onBypassFeedback(player, command);
- + }
- + static String INSERT_DATA = "REPLACE INTO olympiad_nobles (char_id, class_id, olympiad_points) VALUES (?,?,?)";
- + static String OLYMPIAD_UPDATE = "UPDATE olympiad_nobles SET class_id=?, olympiad_points=?, competitions_done=?, competitions_won=?, competitions_lost=?, competitions_drawn=? WHERE char_Id=?";
- + static String DELETE_CHAR_HERO = "DELETE FROM heroes WHERE char_id=?";
- + static String DELETE_CHAR_HENNAS = "DELETE FROM character_hennas WHERE char_obj_id=? AND class_index=?";
- + static String DELETE_CHAR_SUBCLASS = "DELETE FROM character_subclasses WHERE char_obj_id=?";
- + public static void DeleteHero(L2PcInstance player)
- + {
- + try (Connection con = L2DatabaseFactory.getInstance().getConnection(false))
- + {
- + PreparedStatement statement = con.prepareStatement(DELETE_CHAR_HERO);
- + statement.setInt(1, player.getObjectId());
- + statement.execute();
- + statement.close();
- + con.close();
- + }
- + catch (Exception e)
- + {
- + LOGGER.warn("could not clear char Hero: " + e);
- + }
- + }
- + public static void DeleteSubClasses(L2PcInstance player)
- + {
- + try (Connection con = L2DatabaseFactory.getInstance().getConnection(false))
- + {
- + PreparedStatement statement = con.prepareStatement(DELETE_CHAR_SUBCLASS);
- + statement.setInt(1, player.getObjectId());
- + statement.execute();
- + statement.close();
- + con.close();
- + }
- + catch (Exception e)
- + {
- + LOGGER.warn("could not clear char Subclasses: " + e);
- + }
- + }
- + public static void updateClasse(L2PcInstance player)
- + {
- + if (player == null)
- + return;
- +
- + try (Connection con = L2DatabaseFactory.getInstance().getConnection(false))
- + {
- + PreparedStatement stmt = con.prepareStatement(INSERT_DATA);
- +
- + stmt.setInt(1, player.getObjectId());
- + stmt.setInt(2, player.getClassId().getId());
- + stmt.setInt(3, 18);
- + stmt.execute();
- + stmt.close();
- + con.close();
- + }
- + catch (Exception e)
- + {
- + LOGGER.warn("Class Card: Could not clear char Olympiad Points: " + e);
- + }
- + }
- + private static void Finish(L2PcInstance activeChar)
- + {
- + String newclass = activeChar.getTemplate().getClassName();
- + for (final L2Skill skill : activeChar.getAllSkills())
- + {
- + activeChar.removeSkill(skill);
- + }
- + DeleteHenna(activeChar, 0);
- + DeleteSubClasses(activeChar);
- + activeChar.sendMessage(activeChar.getName() + " is now a " + newclass + ".");
- + activeChar.refreshOverloaded();
- + activeChar.store();
- + activeChar.broadcastUserInfo();
- + activeChar.sendSkillList();
- + activeChar.sendPacket(new PlaySound("ItemSound.quest_finish"));
- +
- + if (activeChar.isNoble())
- + {
- + StatsSet playerStat = Olympiad.getNobleStats(activeChar.getObjectId());
- + if (!(playerStat == null))
- + {
- + updateClasse(activeChar);
- + DeleteHero(activeChar);
- + activeChar.sendMessage("You now has " + Olympiad.getInstance().getNoblePoints(activeChar.getObjectId()) + " Olympiad points.");
- + }
- + }
- + activeChar.sendMessage("You will be disconnected for security reasons.");
- + waitSecs(5);
- +
- + activeChar.getClient().closeNow();
- + }
- + public static void waitSecs(int i)
- + {
- + try
- + {
- + Thread.sleep(i * 1000);
- + }
- + catch (InterruptedException e)
- + {
- + e.printStackTrace();
- + }
- + }
- + public static void DeleteHenna(L2PcInstance player, int classIndex)
- + {
- + try (Connection con = L2DatabaseFactory.getInstance().getConnection(false))
- + {
- + // Remove all henna info stored for this sub-class.
- + PreparedStatement statement = con.prepareStatement(DELETE_CHAR_HENNAS);
- + statement.setInt(1, player.getObjectId());
- + statement.setInt(2, classIndex);
- + statement.execute();
- + statement.close();
- + con.close();
- + }
- + catch (Exception e)
- + {
- + LOGGER.warn("could not clear Hennas Dyes: " + e);
- + }
- + }
- +}
- HTML ResetClass.html
- +<html>
- +<body>
- +<center>
- +<font color="0099FF">ResetClass Master</font><br><br>
- +</center>
- +<center>
- +<font color="AAAAAA">Hola, Yo puedo ayudarte a Resetear tus SubClass!</font><br>
- +</center>
- +<font color="AAAAAA">Los Unicos Requisitos son los Siguientes: Tener todas las SubClass & Tercera Profesion!</font><br>
- +<center>
- +<br><br><a action="bypass -h npc_%objectId%_Chat 1"><font color="00AA00">De Acuerdo</font></a><br><br>
- +<br><br><br><br>
- +<center><img src="l2font-e.replay_logo-e" width=255 height=60></center>
- +<br><br><br><br><br><br><br>
- +<font color="00AA00">Lineage Brothers</font>
- +</center>
- +</body>
- +</html>
- HTML ResetClass-1.html
- +<html>
- +<body>
- +<center>
- +<font color="FF9933">Humanos</font>
- +<img src="L2UI.SquareWhite" width=260 height=1>
- +</center>
- +<table width=260><tr><td width=65></td><td width=195>
- +> <a action="bypass -h npc_%objectId%_HumanoF1">Human Fighter</a><br>
- +> <a action="bypass -h npc_%objectId%_HumanoM1">Human Mage</a>
- +</td></tr></table>
- +<center>
- +<img src="L2UI.SquareWhite" width=260 height=1>
- +<font color="FF9933">Elfos Blancos</font>
- +<img src="L2UI.SquareWhite" width=260 height=1>
- +</center>
- +<table width=260><tr><td width=65></td><td width=195>
- +> <a action="bypass -h npc_%objectId%_ElfoBF1">Elf Fighter</a><br>
- +> <a action="bypass -h npc_%objectId%_ElfoBM1">Elf Mage</a>
- +</td></tr></table>
- +<center>
- +<img src="L2UI.SquareWhite" width=260 height=1>
- +<font color="FF9933">Elfos Negros</font>
- +<img src="L2UI.SquareWhite" width=260 height=1>
- +</center>
- +<table width=260><tr><td width=65></td><td width=195>
- +> <a action="bypass -h npc_%objectId%_ElfoNF1">Dark Elf Fighter</a><br>
- +> <a action="bypass -h npc_%objectId%_ElfoNM1">Dark Elf Mage</a>
- +</td></tr></table>
- +<center>
- +<img src="L2UI.SquareWhite" width=260 height=1>
- +<font color="FF9933">Orcos</font>
- +<img src="L2UI.SquareWhite" width=260 height=1>
- +</center>
- +<table width=260><tr><td width=65></td><td width=195>
- +> <a action="bypass -h npc_%objectId%_OrcF1">Orc Fighter</a><br>
- +> <a action="bypass -h npc_%objectId%_OrcoM1">Orc Mage</a>
- +</td></tr></table>
- +<center>
- +<img src="L2UI.SquareWhite" width=260 height=1>
- +<font color="FF9933">Enanos</font>
- +<img src="L2UI.SquareWhite" width=260 height=1>
- +</center>
- +<table width=260><tr><td width=65></td><td width=195>
- +> <a action="bypass -h npc_%objectId%_Enano1">Dwarven Fighter</a><br>
- +</td></tr></table>
- +<img src="L2UI.SquareWhite" width=260 height=1><br>
- +</body>
- +</html>
Add Comment
Please, Sign In to add comment