Advertisement
Guest User

Untitled

a guest
Apr 30th, 2021
1,210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 72.03 KB | None | 0 0
  1. NpcBuffer.java
  2. [code]
  3. /*
  4.  * This file is part of the L2J Mobius project.
  5.  *
  6.  * This program is free software: you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation, either version 3 of the License, or
  9.  * (at your option) any later version.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14.  * General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18.  */
  19. package custom.NpcBuffer;
  20.  
  21. import static org.l2jmobius.gameserver.util.Util.formatAdena;
  22.  
  23. import java.sql.Connection;
  24. import java.sql.PreparedStatement;
  25. import java.sql.ResultSet;
  26. import java.sql.SQLException;
  27. import java.util.ArrayList;
  28. import java.util.Collections;
  29. import java.util.List;
  30. import java.util.logging.Logger;
  31.  
  32. import org.l2jmobius.Config;
  33. import org.l2jmobius.commons.database.DatabaseFactory;
  34. import org.l2jmobius.gameserver.GameServer;
  35. import org.l2jmobius.gameserver.data.xml.impl.SkillData;
  36. import org.l2jmobius.gameserver.instancemanager.QuestManager;
  37. import org.l2jmobius.gameserver.model.actor.Npc;
  38. import org.l2jmobius.gameserver.model.actor.Summon;
  39. import org.l2jmobius.gameserver.model.actor.instance.CubicInstance;
  40. import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
  41. import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
  42. import org.l2jmobius.gameserver.model.actor.instance.ServitorInstance;
  43. import org.l2jmobius.gameserver.model.actor.stat.PlayerStat;
  44. import org.l2jmobius.gameserver.model.actor.stat.SummonStat;
  45. import org.l2jmobius.gameserver.model.actor.status.PlayerStatus;
  46. import org.l2jmobius.gameserver.model.actor.status.SummonStatus;
  47. import org.l2jmobius.gameserver.model.effects.EffectType;
  48. import org.l2jmobius.gameserver.model.entity.TvTEvent;
  49. import org.l2jmobius.gameserver.model.olympiad.OlympiadManager;
  50. import org.l2jmobius.gameserver.model.quest.Quest;
  51. import org.l2jmobius.gameserver.model.quest.QuestState;
  52. import org.l2jmobius.gameserver.model.skills.Skill;
  53. import org.l2jmobius.gameserver.network.SystemMessageId;
  54. import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
  55. import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
  56. import org.l2jmobius.gameserver.network.serverpackets.SetSummonRemainTime;
  57. import org.l2jmobius.gameserver.network.serverpackets.SetupGauge;
  58.  
  59. public class NpcBuffer extends Quest
  60. {
  61.     private static final Logger LOGGER = Logger.getLogger(GameServer.class.getName());
  62.    
  63.     private static final boolean DEBUG = false;
  64.    
  65.     private static void print(Exception e)
  66.     {
  67.        
  68.         LOGGER.warning(">>>" + e.toString() + "<<<");
  69.         if (DEBUG)
  70.         {
  71.             e.printStackTrace();
  72.         }
  73.     }
  74.    
  75.     private static final String QUEST_LOADING_INFO = "NpcBuffer";
  76.     private static final int NPC_ID = Config.NPC_BUFF_NPCID;
  77.    
  78.     private static final String TITLE_NAME = Config.NPC_BUFFER_TITLE;
  79.     private static final boolean SCRIPT_RELOAD = false;
  80.     private static final boolean SMART_WINDOW = true;
  81.     private static final boolean ENABLE_BUFF_SECTION = Config.ENABLE_BUFF_SECTION;
  82.     private static final boolean ENABLE_SCHEME_SYSTEM = Config.ENABLE_SCHEME_SYSTEM;
  83.     private static final boolean ENABLE_HEAL = Config.ENABLE_NPC_BUFFER_HEAL;
  84.     private static final boolean ENABLE_BUFFS = Config.ENABLE_NPC_BUFFER_BUFFS;
  85.     private static final boolean ENABLE_RESIST = Config.ENABLE_NPC_BUFFER_RESIST;
  86.     private static final boolean ENABLE_SONGS = Config.ENABLE_NPC_BUFFER_SONG;
  87.     private static final boolean ENABLE_DANCES = Config.ENABLE_NPC_BUFFER_DANCE;
  88.     private static final boolean ENABLE_CHANTS = Config.ENABLE_NPC_BUFFER_CHANT;
  89.     private static final boolean ENABLE_OTHERS = Config.ENABLE_NPC_BUFFER_OTHERS;
  90.     private static final boolean ENABLE_SPECIAL = Config.ENABLE_NPC_BUFFER_SPECIAL;
  91.     private static final boolean ENABLE_CUBIC = Config.ENABLE_NPC_BUFFER_CUBIC;
  92.     private static final boolean ENABLE_BUFF_REMOVE = Config.ENABLE_NPC_BUFFER_REMOVE;
  93.     private static final boolean ENABLE_BUFF_SET = Config.ENABLE_NPC_BUFFER_SET;
  94.     private static final boolean BUFF_WITH_KARMA = Config.ENABLE_NPC_BUFFER_WITH_KARMA;
  95.     private static final boolean FREE_BUFFS = Config.ENABLE_NPC_BUFFER_FREE;
  96.     private static final boolean TIME_OUT = true;
  97.     private static final int TIME_OUT_TIME = 3;
  98.     private static final int MIN_LEVEL = Config.NPC_BUFFER_MIN_LVL;
  99.     private static final int BUFF_REMOVE_PRICE = Config.NPC_BUFFER_PRICE;
  100.     private static final int HEAL_PRICE = Config.NPC_BUFFER_PRICE;
  101.     private static final int BUFF_PRICE = Config.NPC_BUFFER_PRICE;
  102.     private static final int RESIST_PRICE = Config.NPC_BUFFER_PRICE;
  103.     private static final int SONG_PRICE = Config.NPC_BUFFER_PRICE;
  104.     private static final int DANCE_PRICE = Config.NPC_BUFFER_PRICE;
  105.     private static final int CHANT_PRICE = Config.NPC_BUFFER_PRICE;
  106.     private static final int OTHERS_PRICE = Config.NPC_BUFFER_PRICE;
  107.     private static final int SPECIAL_PRICE = Config.NPC_BUFFER_PRICE;
  108.     private static final int CUBIC_PRICE = Config.NPC_BUFFER_PRICE;
  109.     private static final int BUFF_SET_PRICE = Config.NPC_BUFF_PRICE_SCHEME;
  110.     private static final int SCHEME_BUFF_PRICE = Config.NPC_BUFF_PRICE_SCHEME;
  111.     private static final int SCHEMES_PER_PLAYER = Config.NPC_BUFF_MAX_SCHEME;
  112.     private static final int CONSUMABLE_ID = Config.NPC_BUFFER_ID_ITEM;
  113.     private static final int MAX_SCHEME_BUFFS = Config.NPC_BUFF_MAX_BUFFS;
  114.     private static final int MAX_SCHEME_DANCES = Config.NPC_BUFF_MAX_DANCES_SONGS;
  115.    
  116.     private static final String SET_FIGHTER = "Fighter";
  117.     private static final String SET_MAGE = "Mage";
  118.     private static final String SET_ALL = "All";
  119.     private static final String SET_NONE = "None";
  120.    
  121.     private String rebuildMainHtml(QuestState st)
  122.     {
  123.         String MAIN_HTML_MESSAGE = "<html><head><title>" + TITLE_NAME + "</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32>";
  124.         String MESSAGE = "";
  125.         int td = 0;
  126.         String[] TRS =
  127.         {
  128.             "<tr><td height=25>",
  129.             "</td>",
  130.             "<td height=25>",
  131.             "</td></tr>"
  132.         };
  133.        
  134.         final String bottonA, bottonB, bottonC;
  135.         if (st.getInt("Pet-On-Off") == 1)
  136.         {
  137.             bottonA = "Auto Buff Pet";
  138.             bottonB = "Heal My Pet";
  139.             bottonC = "Remove Pet Buffs";
  140.             MAIN_HTML_MESSAGE += "<button value=\"Pet Options\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " buffpet 0 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">";
  141.         }
  142.         else
  143.         {
  144.             bottonA = "Auto Buff";
  145.             bottonB = "Heal";
  146.             bottonC = "Remove Buffs";
  147.             MAIN_HTML_MESSAGE += "<button value=\"Char Options\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " buffpet 1 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">";
  148.         }
  149.        
  150.         if (ENABLE_BUFF_SECTION)
  151.         {
  152.             if (ENABLE_BUFFS)
  153.             {
  154.                 if (td > 2)
  155.                 {
  156.                     td = 0;
  157.                 }
  158.                 MESSAGE += TRS[td] + "<button value=\"Buffs\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect view_buffs 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + TRS[td + 1];
  159.                 td += 2;
  160.             }
  161.             if (ENABLE_RESIST)
  162.             {
  163.                 if (td > 2)
  164.                 {
  165.                     td = 0;
  166.                 }
  167.                 MESSAGE += TRS[td] + "<button value=\"Resist\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect view_resists 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + TRS[td + 1];
  168.                 td += 2;
  169.             }
  170.             if (ENABLE_SONGS)
  171.             {
  172.                 if (td > 2)
  173.                 {
  174.                     td = 0;
  175.                 }
  176.                 MESSAGE += TRS[td] + "<button value=\"Songs\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect view_songs 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + TRS[td + 1];
  177.                 td += 2;
  178.             }
  179.             if (ENABLE_DANCES)
  180.             {
  181.                 if (td > 2)
  182.                 {
  183.                     td = 0;
  184.                 }
  185.                 MESSAGE += TRS[td] + "<button value=\"Dances\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect view_dances 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + TRS[td + 1];
  186.                 td += 2;
  187.             }
  188.             if (ENABLE_CHANTS)
  189.             {
  190.                 if (td > 2)
  191.                 {
  192.                     td = 0;
  193.                 }
  194.                 MESSAGE += TRS[td] + "<button value=\"Chants\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect view_chants 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + TRS[td + 1];
  195.                 td += 2;
  196.             }
  197.             if (ENABLE_SPECIAL)
  198.             {
  199.                 if (td > 2)
  200.                 {
  201.                     td = 0;
  202.                 }
  203.                 MESSAGE += TRS[td] + "<button value=\"Special\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect view_special 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + TRS[td + 1];
  204.                 td += 2;
  205.             }
  206.             if (ENABLE_OTHERS)
  207.             {
  208.                 if (td > 2)
  209.                 {
  210.                     td = 0;
  211.                 }
  212.                 MESSAGE += TRS[td] + "<button value=\"Others\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect view_others 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + TRS[td + 1];
  213.                 td += 2;
  214.             }
  215.         }
  216.        
  217.         if (ENABLE_CUBIC)
  218.         {
  219.             if (td > 2)
  220.             {
  221.                 td = 0;
  222.             }
  223.             MESSAGE += TRS[td] + "<button value=\"Cubics\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect view_cubic 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + TRS[td + 1];
  224.             td += 2;
  225.         }
  226.        
  227.         if (MESSAGE.length() > 0)
  228.         {
  229.             MAIN_HTML_MESSAGE += "<BR1><table width=100% border=0 cellspacing=0 cellpadding=1 bgcolor=444444><tr>" + "<td><font color=00FFFF>Buffs:</font></td><td align=right>...</td></tr></table>" + "<BR1><table cellspacing=0 cellpadding=0>" + MESSAGE + "</table>";
  230.             MESSAGE = "";
  231.             td = 0;
  232.         }
  233.        
  234.         if (ENABLE_BUFF_SET)
  235.         {
  236.             if (td > 2)
  237.             {
  238.                 td = 0;
  239.             }
  240.             MESSAGE += TRS[td] + "<button value=\"" + bottonA + "\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " castBuffSet 0 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + TRS[td + 1];
  241.             td += 2;
  242.         }
  243.        
  244.         if (ENABLE_HEAL)
  245.         {
  246.             if (td > 2)
  247.             {
  248.                 td = 0;
  249.             }
  250.             MESSAGE += TRS[td] + "<button value=\"" + bottonB + "\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " heal 0 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + TRS[td + 1];
  251.             td += 2;
  252.         }
  253.        
  254.         if (ENABLE_BUFF_REMOVE)
  255.         {
  256.             if (td > 2)
  257.             {
  258.                 td = 0;
  259.             }
  260.             MESSAGE += TRS[td] + "<button value=\"" + bottonC + "\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " removeBuffs 0 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + TRS[td + 1];
  261.             td += 2;
  262.         }
  263.        
  264.         if (MESSAGE.length() > 0)
  265.         {
  266.             MAIN_HTML_MESSAGE += "<BR1><table width=100% border=0 cellspacing=0 cellpadding=1 bgcolor=444444><tr>" + "<td><font color=00FFFF>Preset:</font></td><td align=right><font color=LEVEL>" + formatAdena(BUFF_SET_PRICE) + "</font> adena</td></tr></table>" + "<BR1><table cellspacing=0 cellpadding=0>" + MESSAGE + "</table>";
  267.             MESSAGE = "";
  268.             td = 0;
  269.         }
  270.        
  271.         if (ENABLE_SCHEME_SYSTEM)
  272.         {
  273.             MAIN_HTML_MESSAGE += generateScheme(st);
  274.         }
  275.        
  276.         if (st.getPlayer().isGM())
  277.         {
  278.             MAIN_HTML_MESSAGE += "<br><button value=\"GM Manage Buffs\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect manage_buffs 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">";
  279.         }
  280.         MAIN_HTML_MESSAGE += "<br><font color=303030>" + TITLE_NAME + "</font>" + "</center></body></html>";
  281.         return MAIN_HTML_MESSAGE;
  282.     }
  283.    
  284.     private String generateScheme(QuestState st)
  285.     {
  286.         List<String> schemeName = new ArrayList<>();
  287.         List<String> schemeId = new ArrayList<>();
  288.         String HTML = "";
  289.         try (Connection con = DatabaseFactory.getConnection())
  290.         {
  291.             PreparedStatement rss = con.prepareStatement("SELECT * FROM npcbuffer_scheme_list WHERE player_id=?");
  292.             rss.setInt(1, st.getPlayer().getObjectId());
  293.             ResultSet action = rss.executeQuery();
  294.             while (action.next())
  295.             {
  296.                 schemeName.add(action.getString("scheme_name"));
  297.                 schemeId.add(action.getString("id"));
  298.             }
  299.         }
  300.         catch (SQLException e)
  301.         {
  302.             print(e);
  303.         }
  304.         HTML += "<BR1><table width=100% border=0 cellspacing=0 cellpadding=1 bgcolor=444444><tr>" + "<td><font color=00FFFF>Scheme:</font></td><td align=right><font color=LEVEL>" + formatAdena(SCHEME_BUFF_PRICE) + "</font> adena</TD></TR></table>" + "<BR1><table cellspacing=0 cellpadding=0>";
  305.         if (schemeName.size() > 0)
  306.         {
  307.             String MESSAGE = "";
  308.             int td = 0;
  309.             String[] TRS =
  310.             {
  311.                 "<tr><td>",
  312.                 "</td>",
  313.                 "<td>",
  314.                 "</td></tr>"
  315.             };
  316.             for (int i = 0; i < schemeName.size(); ++i)
  317.             {
  318.                 if (td > 2)
  319.                 {
  320.                     td = 0;
  321.                 }
  322.                 MESSAGE += TRS[td] + "<button value=\"" + schemeName.get(i) + "\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " cast " + schemeId.get(i) + " x x\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + TRS[td + 1];
  323.                 td += 2;
  324.             }
  325.            
  326.             if (MESSAGE.length() > 0)
  327.             {
  328.                 HTML += "<table>" + MESSAGE + "</table>";
  329.             }
  330.         }
  331.        
  332.         if (schemeName.size() < SCHEMES_PER_PLAYER)
  333.         {
  334.             HTML += "<BR1><table><tr><td><button value=\"Create\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " create_1 x x x\" width=85 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>";
  335.         }
  336.         else
  337.         {
  338.             HTML += "<BR1><table width=100><tr>";
  339.         }
  340.        
  341.         if (schemeName.size() > 0)
  342.         {
  343.             HTML += "<td><button value=\"Edit\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_1 x x x\" width=85 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>" + "<td><button value=\"Delete\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " delete_1 x x x\" width=85 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table>";
  344.         }
  345.         else
  346.         {
  347.             HTML += "</tr></table>";
  348.         }
  349.         return HTML;
  350.     }
  351.    
  352.     private String reloadPanel(QuestState st)
  353.     {
  354.         return "<html><head><title>" + TITLE_NAME + "</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>" + "<font color=303030>" + TITLE_NAME + "</font><br>" + "<img src=\"L2UI.SquareGray\" width=250 height=1><br>" + "<table width=260 border=0 bgcolor=444444>" + "<tr><td><br></td></tr>" + "<tr><td align=center><font color=FFFFFF>This option can be seen by GMs only and it<br1>allow to update any changes made in the<br1>script. You can disable this option in<br1>the settings section within the Script.<br><font color=LEVEL>Do you want to update the SCRIPT?</font></font></td></tr>" + "<tr><td></td></tr></table><br>" + "<img src=\"L2UI.SquareGray\" width=250 height=1><br><br>" + "<button value=\"Yes\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " reloadscript 1 0 0\" width=50 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + "<button value=\"No\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " reloadscript 0 0 0\" width=50 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + "</center></body></html>";
  355.     }
  356.    
  357.     private String getItemNameHtml(QuestState st, int itemval)
  358.     {
  359.         return "&#" + itemval + ";";
  360.     }
  361.    
  362.     private int getBuffCount(String scheme)
  363.     {
  364.         int count = 0;
  365.         try (Connection con = DatabaseFactory.getConnection())
  366.         {
  367.             PreparedStatement rss = con.prepareStatement("SELECT buff_class FROM npcbuffer_scheme_contents WHERE scheme_id=?");
  368.             rss.setString(1, scheme);
  369.             ResultSet action = rss.executeQuery();
  370.             while (action.next())
  371.             {
  372.                 ++count;
  373.             }
  374.         }
  375.         catch (SQLException e)
  376.         {
  377.             print(e);
  378.         }
  379.         return count;
  380.     }
  381.    
  382.     private String getBuffType(int id)
  383.     {
  384.         String val = "none";
  385.         try (Connection con = DatabaseFactory.getConnection())
  386.         {
  387.             PreparedStatement act = con.prepareStatement("SELECT buffType FROM npcbuffer_buff_list WHERE buffId=? LIMIT 1");
  388.             act.setInt(1, id);
  389.             ResultSet rs = act.executeQuery();
  390.             if (rs.next())
  391.             {
  392.                 val = rs.getString("buffType");
  393.             }
  394.         }
  395.         catch (SQLException e)
  396.         {
  397.             print(e);
  398.         }
  399.         return val;
  400.     }
  401.    
  402.     private boolean isEnabled(int id, int level)
  403.     {
  404.         boolean val = false;
  405.         try (Connection con = DatabaseFactory.getConnection())
  406.         {
  407.             PreparedStatement act = con.prepareStatement("SELECT canUse FROM npcbuffer_buff_list WHERE buffId=? AND buffLevel=? LIMIT 1");
  408.             act.setInt(1, id);
  409.             act.setInt(2, level);
  410.             ResultSet rs = act.executeQuery();
  411.             if (rs.next())
  412.             {
  413.                 if ("1".equals(rs.getString("canUse")))
  414.                 {
  415.                     val = true;
  416.                 }
  417.             }
  418.         }
  419.         catch (SQLException e)
  420.         {
  421.             print(e);
  422.         }
  423.         return val;
  424.     }
  425.    
  426.     private boolean isUsed(String scheme, int id, int level)
  427.     {
  428.         boolean used = false;
  429.         try (Connection con = DatabaseFactory.getConnection())
  430.         {
  431.             PreparedStatement rss = con.prepareStatement("SELECT id FROM npcbuffer_scheme_contents WHERE scheme_id=? AND skill_id=? AND skill_level=? LIMIT 1");
  432.             rss.setString(1, scheme);
  433.             rss.setInt(2, id);
  434.             rss.setInt(3, level);
  435.             ResultSet action = rss.executeQuery();
  436.             if (action.next())
  437.             {
  438.                 used = true;
  439.             }
  440.         }
  441.         catch (SQLException e)
  442.         {
  443.             print(e);
  444.         }
  445.         return used;
  446.     }
  447.    
  448.     private int getClassBuff(String id)
  449.     {
  450.         int val = 0;
  451.         try (Connection con = DatabaseFactory.getConnection())
  452.         {
  453.             PreparedStatement getTipo = con.prepareStatement("SELECT buff_class FROM npcbuffer_buff_list WHERE buffId=?");
  454.             getTipo.setString(1, id);
  455.             ResultSet gt = getTipo.executeQuery();
  456.             if (gt.next())
  457.             {
  458.                 val = gt.getInt("buff_class");
  459.             }
  460.         }
  461.         catch (SQLException e)
  462.         {
  463.             print(e);
  464.         }
  465.         return val;
  466.     }
  467.    
  468.     private String showText(QuestState st, String type, String text, boolean buttonEnabled, String buttonName, String location)
  469.     {
  470.         String MESSAGE = "<html><head><title>" + TITLE_NAME + "</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>";
  471.         MESSAGE += "<font color=LEVEL>" + type + "</font><br>" + text + "<br>";
  472.         if (buttonEnabled)
  473.         {
  474.             MESSAGE += "<button value=\"" + buttonName + "\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect " + location + " 0 0\" width=100 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">";
  475.         }
  476.         MESSAGE += "<font color=303030>" + TITLE_NAME + "</font></center></body></html>";
  477.         return MESSAGE;
  478.     }
  479.    
  480.     private String reloadConfig(QuestState st)
  481.     {
  482.         try
  483.         {
  484.             if (QuestManager.getInstance().reload(QUEST_LOADING_INFO))
  485.             {
  486.                 st.getPlayer().sendMessage("The script and settings have been reloaded successfully.");
  487.             }
  488.             else
  489.             {
  490.                 st.getPlayer().sendMessage("Script Reloaded Failed. you edited something wrong! :P, fix it and restart the server");
  491.             }
  492.         }
  493.         catch (Exception e)
  494.         {
  495.             st.getPlayer().sendMessage("Script Reloaded Failed. you edited something wrong! :P, fix it and restart the server");
  496.             print(e);
  497.         }
  498.         return rebuildMainHtml(st);
  499.     }
  500.    
  501.     private NpcBuffer()
  502.     {
  503.         super(-1);
  504.         addStartNpc(NPC_ID);
  505.         addFirstTalkId(NPC_ID);
  506.         addTalkId(NPC_ID);
  507.     }
  508.    
  509.     private boolean isPetBuff(QuestState st)
  510.     {
  511.         return st.getInt("Pet-On-Off") != 0;
  512.     }
  513.    
  514.     private String createScheme()
  515.     {
  516.         return "<html><head><title>" + TITLE_NAME + "</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>You MUST seprerate new words with a dot (.)<br><br>Scheme name: <edit var=\"name\" width=100><br><br>" + "<button value=\"Create Scheme\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " create $name no_name x x\" width=200 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + "<br><button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + "<br><font color=303030>" + TITLE_NAME + "</font></center></body></html>";
  517.     }
  518.    
  519.     private String deleteScheme(PlayerInstance player)
  520.     {
  521.         String HTML = "<html><head><title>" + TITLE_NAME + "</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>Available schemes:<br><br>";
  522.         try (Connection con = DatabaseFactory.getConnection())
  523.         {
  524.             PreparedStatement rss = con.prepareStatement("SELECT * FROM npcbuffer_scheme_list WHERE player_id=?");
  525.             rss.setInt(1, player.getObjectId());
  526.             ResultSet action = rss.executeQuery();
  527.             while (action.next())
  528.             {
  529.                 HTML += "<button value=\"" + action.getString("scheme_name") + "\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " delete_c " + action.getString("id") + " " + action.getString("scheme_name") + " x\" width=200 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">";
  530.             }
  531.         }
  532.         catch (SQLException e)
  533.         {
  534.             print(e);
  535.         }
  536.         HTML += "<br><button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + "<br><font color=303030>" + TITLE_NAME + "</font></center></body></html>";
  537.         return HTML;
  538.     }
  539.    
  540.     private String editScheme(PlayerInstance player)
  541.     {
  542.         String HTML = "<html><head><title>" + TITLE_NAME + "</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>Select a scheme that you would like to manage:<br><br>";
  543.         try (Connection con = DatabaseFactory.getConnection())
  544.         {
  545.             PreparedStatement rss = con.prepareStatement("SELECT * FROM npcbuffer_scheme_list WHERE player_id=?");
  546.             rss.setInt(1, player.getObjectId());
  547.             ResultSet action = rss.executeQuery();
  548.             while (action.next())
  549.             {
  550.                 String name = action.getString("scheme_name");
  551.                 String id = action.getString("id");
  552.                 HTML += "<button value=\"" + name + "\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " manage_scheme_select " + id + " x x\" width=200 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">";
  553.             }
  554.         }
  555.         catch (SQLException e)
  556.         {
  557.             print(e);
  558.         }
  559.         HTML += "<br><button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + "<br><font color=303030>" + TITLE_NAME + "</font></center></body></html>";
  560.         return HTML;
  561.     }
  562.    
  563.     private String getOptionList(String scheme)
  564.     {
  565.         int bcount = getBuffCount(scheme);
  566.         String HTML = "<html><head><title>" + TITLE_NAME + "</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>There are <font color=LEVEL>" + bcount + "</font> buffs in current scheme!<br><br>";
  567.         if (bcount < (MAX_SCHEME_BUFFS + MAX_SCHEME_DANCES))
  568.         {
  569.             HTML += "<button value=\"Add buffs\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " manage_scheme_1 " + scheme + " 1 x\" width=200 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">";
  570.         }
  571.         if (bcount > 0)
  572.         {
  573.             HTML += "<button value=\"Remove buffs\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " manage_scheme_2 " + scheme + " 1 x\" width=200 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">";
  574.         }
  575.         HTML += "<br><button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_1 0 0 0\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + "<button value=\"Home\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + "<br><font color=303030>" + TITLE_NAME + "</font></center></body></html>";
  576.         return HTML;
  577.     }
  578.    
  579.     private String buildHtml(String buffType)
  580.     {
  581.         String HTML_MESSAGE = "<html><head><title>" + TITLE_NAME + "</title></head><body><center><br>";
  582.        
  583.         List<String> availableBuffs = new ArrayList<>();
  584.         try (Connection con = DatabaseFactory.getConnection())
  585.         {
  586.             PreparedStatement getList = con.prepareStatement("SELECT buffId,buffLevel FROM npcbuffer_buff_list WHERE buffType=\"" + buffType + "\" AND canUse=1  ORDER BY Buff_Class ASC, id");
  587.             ResultSet rs = getList.executeQuery();
  588.             while (rs.next())
  589.             {
  590.                 int bId = rs.getInt("buffId");
  591.                 int bLevel = rs.getInt("buffLevel");
  592.                 String bName = SkillData.getInstance().getSkill(bId, bLevel).getName();
  593.                 bName = bName.replace(" ", "+");
  594.                 availableBuffs.add(bName + "_" + bId + "_" + bLevel);
  595.             }
  596.         }
  597.         catch (SQLException e)
  598.         {
  599.             print(e);
  600.         }
  601.        
  602.         if (availableBuffs.size() == 0)
  603.         {
  604.             HTML_MESSAGE += "No buffs are available at this moment!";
  605.         }
  606.         else
  607.         {
  608.             if (FREE_BUFFS)
  609.             {
  610.                 HTML_MESSAGE += "All buffs are for <font color=LEVEL>free</font>!";
  611.             }
  612.             else
  613.             {
  614.                 int price = 0;
  615.                 switch (buffType)
  616.                 {
  617.                     case "buff":
  618.                         price = BUFF_PRICE;
  619.                         break;
  620.                     case "resist":
  621.                         price = RESIST_PRICE;
  622.                         break;
  623.                     case "song":
  624.                         price = SONG_PRICE;
  625.                         break;
  626.                     case "dance":
  627.                         price = DANCE_PRICE;
  628.                         break;
  629.                     case "chant":
  630.                         price = CHANT_PRICE;
  631.                         break;
  632.                     case "others":
  633.                         price = OTHERS_PRICE;
  634.                         break;
  635.                     case "special":
  636.                         price = SPECIAL_PRICE;
  637.                         break;
  638.                     case "cubic":
  639.                         price = CUBIC_PRICE;
  640.                         break;
  641.                     default:
  642.                         if (DEBUG)
  643.                         {
  644.                             throw new RuntimeException();
  645.                         }
  646.                 }
  647.                 HTML_MESSAGE += "All special buffs cost <font color=LEVEL>" + formatAdena(price) + "</font> adena!";
  648.             }
  649.             HTML_MESSAGE += "<BR1><table>";
  650.             for (String buff : availableBuffs)
  651.             {
  652.                 buff = buff.replace("_", " ");
  653.                 String[] buffSplit = buff.split(" ");
  654.                 String name = buffSplit[0];
  655.                 int id = Integer.parseInt(buffSplit[1]);
  656.                 int level = Integer.parseInt(buffSplit[2]);
  657.                 name = name.replace("+", " ");
  658.                 HTML_MESSAGE += "<tr><td>" + getSkillIconHtml(id, level) + "</td><td><button value=\"" + name + "\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " giveBuffs " + id + " " + level + " " + buffType + "\" width=190 height=32 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>";
  659.             }
  660.             HTML_MESSAGE += "</table>";
  661.         }
  662.        
  663.         HTML_MESSAGE += "<br><button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + "<br><font color=303030>" + TITLE_NAME + "</font></center></body></html>";
  664.         return HTML_MESSAGE;
  665.     }
  666.    
  667.     private String generateQuery(int case1, int case2)
  668.     {
  669.         StringBuilder qry = new StringBuilder();
  670.         if (ENABLE_BUFFS)
  671.         {
  672.             if (case1 < MAX_SCHEME_BUFFS)
  673.             {
  674.                 qry.append(",\"buff\"");
  675.             }
  676.         }
  677.         if (ENABLE_RESIST)
  678.         {
  679.             if (case1 < MAX_SCHEME_BUFFS)
  680.             {
  681.                 qry.append(",\"resist\"");
  682.             }
  683.         }
  684.         if (ENABLE_SONGS)
  685.         {
  686.             if (case2 < MAX_SCHEME_DANCES)
  687.             {
  688.                 qry.append(",\"song\"");
  689.             }
  690.         }
  691.         if (ENABLE_DANCES)
  692.         {
  693.             if (case2 < MAX_SCHEME_DANCES)
  694.             {
  695.                 qry.append(",\"dance\"");
  696.             }
  697.         }
  698.         if (ENABLE_CHANTS)
  699.         {
  700.             if (case1 < MAX_SCHEME_BUFFS)
  701.             {
  702.                 qry.append(",\"chant\"");
  703.             }
  704.         }
  705.         if (ENABLE_OTHERS)
  706.         {
  707.             if (case1 < MAX_SCHEME_BUFFS)
  708.             {
  709.                 qry.append(",\"others\"");
  710.             }
  711.         }
  712.         if (ENABLE_SPECIAL)
  713.         {
  714.             if (case1 < MAX_SCHEME_BUFFS)
  715.             {
  716.                 qry.append(",\"special\"");
  717.             }
  718.         }
  719.         if (qry.length() > 0)
  720.         {
  721.             qry.deleteCharAt(0);
  722.         }
  723.         return qry.toString();
  724.     }
  725.    
  726.     private String viewAllSchemeBuffs$getBuffCount(String scheme)
  727.     {
  728.         int count = 0;
  729.         int D_S_Count = 0;
  730.         int B_Count = 0;
  731.         try (Connection con = DatabaseFactory.getConnection())
  732.         {
  733.             PreparedStatement rss = con.prepareStatement("SELECT buff_class FROM npcbuffer_scheme_contents WHERE scheme_id=?");
  734.             rss.setString(1, scheme);
  735.             ResultSet action = rss.executeQuery();
  736.             while (action.next())
  737.             {
  738.                 ++count;
  739.                 int val = action.getInt("buff_class");
  740.                 if ((val == 1) || (val == 2))
  741.                 {
  742.                     ++D_S_Count;
  743.                 }
  744.                 else
  745.                 {
  746.                     ++B_Count;
  747.                 }
  748.             }
  749.         }
  750.         catch (SQLException e)
  751.         {
  752.             print(e);
  753.         }
  754.         String res = count + " " + B_Count + " " + D_S_Count;
  755.         return res;
  756.     }
  757.    
  758.     private String viewAllSchemeBuffs(String scheme, String page, String action)
  759.     {
  760.         List<String> buffList = new ArrayList<>();
  761.         String HTML_MESSAGE = "<html><head><title>" + TITLE_NAME + "</title></head><body><center><br>";
  762.         String[] eventSplit = viewAllSchemeBuffs$getBuffCount(scheme).split(" ");
  763.         int TOTAL_BUFF = Integer.parseInt(eventSplit[0]);
  764.         int BUFF_COUNT = Integer.parseInt(eventSplit[1]);
  765.         int DANCE_SONG = Integer.parseInt(eventSplit[2]);
  766.         try (Connection con = DatabaseFactory.getConnection())
  767.         {
  768.             if (action.equals("add"))
  769.             {
  770.                 HTML_MESSAGE += "You can add <font color=LEVEL>" + (MAX_SCHEME_BUFFS - BUFF_COUNT) + "</font> Buffs and <font color=LEVEL>" + (MAX_SCHEME_DANCES - DANCE_SONG) + "</font> Dances more!";
  771.                 String QUERY = "SELECT * FROM npcbuffer_buff_list WHERE buffType IN (" + generateQuery(BUFF_COUNT, DANCE_SONG) + ") AND canUse=1 ORDER BY Buff_Class ASC, id";
  772.                 PreparedStatement getBuffCount = con.prepareStatement(QUERY);
  773.                 ResultSet rss = getBuffCount.executeQuery();
  774.                 while (rss.next())
  775.                 {
  776.                     String name = SkillData.getInstance().getSkill(rss.getInt("buffId"), rss.getInt("buffLevel")).getName();
  777.                     name = name.replace(" ", "+");
  778.                     buffList.add(name + "_" + rss.getInt("buffId") + "_" + rss.getInt("buffLevel"));
  779.                 }
  780.             }
  781.             else if (action.equals("remove"))
  782.             {
  783.                 HTML_MESSAGE += "You have <font color=LEVEL>" + BUFF_COUNT + "</font> Buffs and <font color=LEVEL>" + DANCE_SONG + "</font> Dances";
  784.                 String QUERY = "SELECT * FROM npcbuffer_scheme_contents WHERE scheme_id=? ORDER BY Buff_Class ASC, id";
  785.                 PreparedStatement getBuffCount = con.prepareStatement(QUERY);
  786.                 getBuffCount.setString(1, scheme);
  787.                 ResultSet rss = getBuffCount.executeQuery();
  788.                 while (rss.next())
  789.                 {
  790.                     String name = SkillData.getInstance().getSkill(rss.getInt("skill_id"), rss.getInt("skill_level")).getName();
  791.                     name = name.replace(" ", "+");
  792.                     buffList.add(name + "_" + rss.getInt("skill_id") + "_" + rss.getInt("skill_level"));
  793.                 }
  794.             }
  795.             else if (DEBUG)
  796.             {
  797.                 throw new RuntimeException();
  798.             }
  799.         }
  800.         catch (SQLException e)
  801.         {
  802.             print(e);
  803.         }
  804.        
  805.         HTML_MESSAGE += "<BR1><table border=0><tr>";
  806.         final int buffsPerPage = 20;
  807.         final String width, pageName;
  808.         int pc = ((buffList.size() - 1) / buffsPerPage) + 1;
  809.         if (pc > 5)
  810.         {
  811.             width = "25";
  812.             pageName = "P";
  813.         }
  814.         else
  815.         {
  816.             width = "50";
  817.             pageName = "Page ";
  818.         }
  819.         for (int ii = 1; ii <= pc; ++ii)
  820.         {
  821.             if (ii == Integer.parseInt(page))
  822.             {
  823.                 HTML_MESSAGE += "<td width=" + width + " align=center><font color=LEVEL>" + pageName + ii + "</font></td>";
  824.             }
  825.             else if (action.equals("add"))
  826.             {
  827.                 HTML_MESSAGE += "<td width=" + width + ">" + "<button value=\"" + pageName + ii + "\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " manage_scheme_1 " + scheme + " " + ii + " x\" width=" + width + " height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>";
  828.             }
  829.             else if (action.equals("remove"))
  830.             {
  831.                 HTML_MESSAGE += "<td width=" + width + ">" + "<button value=\"" + pageName + ii + "\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " manage_scheme_2 " + scheme + " " + ii + " x\" width=" + width + " height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>";
  832.             }
  833.             else if (DEBUG)
  834.             {
  835.                 throw new RuntimeException();
  836.             }
  837.         }
  838.         HTML_MESSAGE += "</tr></table>";
  839.        
  840.         int limit = buffsPerPage * Integer.parseInt(page);
  841.         int start = limit - buffsPerPage;
  842.         int end = Math.min(limit, buffList.size());
  843.         int k = 0;
  844.         for (int i = start; i < end; ++i)
  845.         {
  846.             String value = buffList.get(i);
  847.             value = value.replace("_", " ");
  848.             String[] extr = value.split(" ");
  849.             String name = extr[0];
  850.             name = name.replace("+", " ");
  851.             int id = Integer.parseInt(extr[1]);
  852.             int level = Integer.parseInt(extr[2]);
  853.             if (action.equals("add"))
  854.             {
  855.                 if (!isUsed(scheme, id, level))
  856.                 {
  857.                     if ((k % 2) != 0)
  858.                     {
  859.                         HTML_MESSAGE += "<BR1><table border=0 bgcolor=333333>";
  860.                     }
  861.                     else
  862.                     {
  863.                         HTML_MESSAGE += "<BR1><table border=0 bgcolor=292929>";
  864.                     }
  865.                     HTML_MESSAGE += "<tr><td width=35>" + getSkillIconHtml(id, level) + "</td><td fixwidth=170>" + name + "</td><td><button value=\"Add\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " add_buff " + scheme + "_" + id + "_" + level + " " + page + " " + TOTAL_BUFF + "\" width=65 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>" + "</tr></table>";
  866.                     k += 1;
  867.                 }
  868.             }
  869.             else if (action.equals("remove"))
  870.             {
  871.                 if ((k % 2) != 0)
  872.                 {
  873.                     HTML_MESSAGE += "<BR1><table border=0 bgcolor=333333>";
  874.                 }
  875.                 else
  876.                 {
  877.                     HTML_MESSAGE += "<BR1><table border=0 bgcolor=292929>";
  878.                 }
  879.                 HTML_MESSAGE += "<tr><td width=35>" + getSkillIconHtml(id, level) + "</td><td fixwidth=170>" + name + "</td><td><button value=\"Remove\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " remove_buff " + scheme + "_" + id + "_" + level + " " + page + " " + TOTAL_BUFF + "\" width=65 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>" + "</table>";
  880.                 k += 1;
  881.             }
  882.         }
  883.         HTML_MESSAGE += "<br><br><button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " manage_scheme_select " + scheme + " x x\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + "<button value=\"Home\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + "<br><font color=303030>" + TITLE_NAME + "</font></center></body></html>";
  884.         return HTML_MESSAGE;
  885.     }
  886.    
  887.     private String viewAllBuffTypes()
  888.     {
  889.         String HTML_MESSAGE = "<html><head><title>" + TITLE_NAME + "</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>";
  890.         HTML_MESSAGE += "<font color=LEVEL>[Buff management]</font><br>";
  891.         if (ENABLE_BUFFS)
  892.         {
  893.             HTML_MESSAGE += "<button value=\"Buffs\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_buff_list buff Buffs 1\" width=200 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">";
  894.         }
  895.         if (ENABLE_RESIST)
  896.         {
  897.             HTML_MESSAGE += "<button value=\"Resist Buffs\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_buff_list resist Resists 1\" width=200 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">";
  898.         }
  899.         if (ENABLE_SONGS)
  900.         {
  901.             HTML_MESSAGE += "<button value=\"Songs\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_buff_list song Songs 1\" width=200 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">";
  902.         }
  903.         if (ENABLE_DANCES)
  904.         {
  905.             HTML_MESSAGE += "<button value=\"Dances\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_buff_list dance Dances 1\" width=200 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">";
  906.         }
  907.         if (ENABLE_CHANTS)
  908.         {
  909.             HTML_MESSAGE += "<button value=\"Chants\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_buff_list chant Chants 1\" width=200 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">";
  910.         }
  911.         if (ENABLE_SPECIAL)
  912.         {
  913.             HTML_MESSAGE += "<button value=\"Special Buffs\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_buff_list special Special_Buffs 1\" width=200 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">";
  914.         }
  915.         if (ENABLE_OTHERS)
  916.         {
  917.             HTML_MESSAGE += "<button value=\"Others Buffs\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_buff_list others Others_Buffs 1\" width=200 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">";
  918.         }
  919.         if (ENABLE_CUBIC)
  920.         {
  921.             HTML_MESSAGE += "<button value=\"Cubics\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_buff_list cubic cubic_Buffs 1\" width=200 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">";
  922.         }
  923.         if (ENABLE_BUFF_SET)
  924.         {
  925.             HTML_MESSAGE += "<button value=\"Buff Sets\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_buff_list set Buff_Sets 1\" width=200 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><br>";
  926.         }
  927.         HTML_MESSAGE += "<button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + "<br><font color=303030>" + TITLE_NAME + "</font></center></body></html>";
  928.         return HTML_MESSAGE;
  929.     }
  930.    
  931.     private String viewAllBuffs(String type, String typeName, String page)
  932.     {
  933.         List<String> buffList = new ArrayList<>();
  934.         String HTML_MESSAGE = "<html><head><title>" + TITLE_NAME + "</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>";
  935.         typeName = typeName.replace("_", " ");
  936.         try (Connection con = DatabaseFactory.getConnection())
  937.         {
  938.             final PreparedStatement getBuffCount;
  939.             if (type.equals("set"))
  940.             {
  941.                 getBuffCount = con.prepareStatement("SELECT * FROM npcbuffer_buff_list WHERE buffType IN (" + generateQuery(0, 0) + ") AND canUse=1");
  942.             }
  943.             else
  944.             {
  945.                 getBuffCount = con.prepareStatement("SELECT * FROM npcbuffer_buff_list WHERE buffType=?");
  946.                 getBuffCount.setString(1, type);
  947.             }
  948.             ResultSet rss = getBuffCount.executeQuery();
  949.             while (rss.next())
  950.             {
  951.                 String name = SkillData.getInstance().getSkill(rss.getInt("buffId"), rss.getInt("buffLevel")).getName();
  952.                 name = name.replace(" ", "+");
  953.                 String usable = rss.getString("canUse");
  954.                 String forClass = rss.getString("forClass");
  955.                 String skill_id = rss.getString("buffId");
  956.                 String skill_level = rss.getString("buffLevel");
  957.                 buffList.add(name + "_" + forClass + "_" + page + "_" + usable + "_" + skill_id + "_" + skill_level);
  958.             }
  959.         }
  960.         catch (SQLException e)
  961.         {
  962.             print(e);
  963.         }
  964.         Collections.sort(buffList);
  965.        
  966.         HTML_MESSAGE += "<font color=LEVEL>[Buff management - " + typeName + " - Page " + page + "]</font><br><table border=0><tr>";
  967.         final int buffsPerPage;
  968.         if (type.equals("set"))
  969.         {
  970.             buffsPerPage = 12;
  971.         }
  972.         else
  973.         {
  974.             buffsPerPage = 20;
  975.         }
  976.         final String width, pageName;
  977.         int pc = ((buffList.size() - 1) / buffsPerPage) + 1;
  978.         if (pc > 5)
  979.         {
  980.             width = "25";
  981.             pageName = "P";
  982.         }
  983.         else
  984.         {
  985.             width = "50";
  986.             pageName = "Page ";
  987.         }
  988.         typeName = typeName.replace(" ", "_");
  989.         for (int ii = 1; ii <= pc; ++ii)
  990.         {
  991.             if (ii == Integer.parseInt(page))
  992.             {
  993.                 HTML_MESSAGE += "<td width=" + width + " align=center><font color=LEVEL>" + pageName + ii + "</font></td>";
  994.             }
  995.             else
  996.             {
  997.                 HTML_MESSAGE += "<td width=" + width + "><button value=\"" + pageName + "" + ii + "\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_buff_list " + type + " " + typeName + " " + ii + "\" width=" + width + " height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>";
  998.             }
  999.         }
  1000.         HTML_MESSAGE += "</tr></table><br>";
  1001.        
  1002.         int limit = buffsPerPage * Integer.parseInt(page);
  1003.         int start = limit - buffsPerPage;
  1004.         int end = Math.min(limit, buffList.size());
  1005.         for (int i = start; i < end; ++i)
  1006.         {
  1007.             String value = buffList.get(i);
  1008.             value = value.replace("_", " ");
  1009.             String[] extr = value.split(" ");
  1010.             String name = extr[0];
  1011.             name = name.replace("+", " ");
  1012.             int forClass = Integer.parseInt(extr[1]);
  1013.             int usable = Integer.parseInt(extr[3]);
  1014.             String skillPos = extr[4] + "_" + extr[5];
  1015.             if ((i % 2) != 0)
  1016.             {
  1017.                 HTML_MESSAGE += "<BR1><table border=0 bgcolor=333333>";
  1018.             }
  1019.             else
  1020.             {
  1021.                 HTML_MESSAGE += "<BR1><table border=0 bgcolor=292929>";
  1022.             }
  1023.             if (type.equals("set"))
  1024.             {
  1025.                 String listOrder = null;
  1026.                 if (forClass == 0)
  1027.                 {
  1028.                     listOrder = "List=\"" + SET_FIGHTER + ";" + SET_MAGE + ";" + SET_ALL + ";" + SET_NONE + ";\"";
  1029.                 }
  1030.                 else if (forClass == 1)
  1031.                 {
  1032.                     listOrder = "List=\"" + SET_MAGE + ";" + SET_FIGHTER + ";" + SET_ALL + ";" + SET_NONE + ";\"";
  1033.                 }
  1034.                 else if (forClass == 2)
  1035.                 {
  1036.                     listOrder = "List=\"" + SET_ALL + ";" + SET_FIGHTER + ";" + SET_MAGE + ";" + SET_NONE + ";\"";
  1037.                 }
  1038.                 else if (forClass == 3)
  1039.                 {
  1040.                     listOrder = "List=\"" + SET_NONE + ";" + SET_FIGHTER + ";" + SET_MAGE + ";" + SET_ALL + ";\"";
  1041.                 }
  1042.                 HTML_MESSAGE += "<tr><td fixwidth=145>" + name + "</td><td width=70><combobox var=\"newSet" + i + "\" width=70 " + listOrder + "></td>" + "<td width=50><button value=\"Update\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " changeBuffSet " + skillPos + " $newSet" + i + " " + page + "\" width=50 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>";
  1043.             }
  1044.             else
  1045.             {
  1046.                 HTML_MESSAGE += "<tr><td fixwidth=170>" + name + "</td><td width=80>";
  1047.                 if (usable == 1)
  1048.                 {
  1049.                     HTML_MESSAGE += "<button value=\"Disable\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " editSelectedBuff " + skillPos + " 0-" + page + " " + type + "\" width=80 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>";
  1050.                 }
  1051.                 else if (usable == 0)
  1052.                 {
  1053.                     HTML_MESSAGE += "<button value=\"Enable\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " editSelectedBuff " + skillPos + " 1-" + page + " " + type + "\" width=80 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>";
  1054.                 }
  1055.             }
  1056.             HTML_MESSAGE += "</table>";
  1057.         }
  1058.         HTML_MESSAGE += "<br><br><button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect manage_buffs 0 0\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + "<button value=\"Home\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + "<br><font color=303030>" + TITLE_NAME + "</font></center></body></html>";
  1059.         return HTML_MESSAGE;
  1060.     }
  1061.    
  1062.     private void manageSelectedBuff(String buffPosId, String canUseBuff)
  1063.     {
  1064.         String[] bpid = buffPosId.split("_");
  1065.         String bId = bpid[0];
  1066.         String bLvl = bpid[1];
  1067.         try (Connection con = DatabaseFactory.getConnection())
  1068.         {
  1069.             PreparedStatement upd = con.prepareStatement("UPDATE npcbuffer_buff_list SET canUse=? WHERE buffId=? AND buffLevel=? LIMIT 1");
  1070.             upd.setString(1, canUseBuff);
  1071.             upd.setString(2, bId);
  1072.             upd.setString(3, bLvl);
  1073.             upd.executeUpdate();
  1074.             upd.close();
  1075.         }
  1076.         catch (SQLException e)
  1077.         {
  1078.             print(e);
  1079.         }
  1080.     }
  1081.    
  1082.     private String manageSelectedSet(String id, String newVal, String opt3)
  1083.     {
  1084.         String[] bpid = id.split("_");
  1085.         String bId = bpid[0];
  1086.         String bLvl = bpid[1];
  1087.         try (Connection con = DatabaseFactory.getConnection())
  1088.         {
  1089.             PreparedStatement upd = con.prepareStatement("UPDATE npcbuffer_buff_list SET forClass=? WHERE buffId=? AND bufflevel=?");
  1090.             upd.setString(1, newVal);
  1091.             upd.setString(2, bId);
  1092.             upd.setString(3, bLvl);
  1093.             upd.executeUpdate();
  1094.             upd.close();
  1095.         }
  1096.         catch (SQLException e)
  1097.         {
  1098.             print(e);
  1099.         }
  1100.         return viewAllBuffs("set", "Buff Sets", opt3);
  1101.     }
  1102.    
  1103.     private void addTimeout(QuestState st, int gaugeColor, int amount, int offset)
  1104.     {
  1105.         int endtime = (int) ((System.currentTimeMillis() + (amount * 1000)) / 1000);
  1106.         st.set("blockUntilTime", String.valueOf(endtime));
  1107.         st.getPlayer().sendPacket(new SetupGauge(gaugeColor, (amount * 1000) + offset, endtime));
  1108.     }
  1109.    
  1110.     private void heal(PlayerInstance player, boolean isPet)
  1111.     {
  1112.         Summon target;
  1113.         if (!isPet)
  1114.         {
  1115.             PlayerStatus pcStatus = player.getStatus();
  1116.             PlayerStat pcStat = player.getStat();
  1117.             pcStatus.setCurrentHp(pcStat.getMaxHp());
  1118.             pcStatus.setCurrentMp(pcStat.getMaxMp());
  1119.             pcStatus.setCurrentCp(pcStat.getMaxCp());
  1120.         }
  1121.         else if ((target = player.getSummon()) != null)
  1122.         {
  1123.             SummonStatus petStatus = target.getStatus();
  1124.             SummonStat petStat = target.getStat();
  1125.             petStatus.setCurrentHp(petStat.getMaxHp());
  1126.             petStatus.setCurrentMp(petStat.getMaxMp());
  1127.             if (target instanceof PetInstance)
  1128.             {
  1129.                 PetInstance pet = (PetInstance) target;
  1130.                 pet.setCurrentFed(pet.getMaxFed());
  1131.                 player.sendPacket(new SetSummonRemainTime(pet.getMaxFed(), pet.getCurrentFed()));
  1132.             }
  1133.             else if (target instanceof ServitorInstance)
  1134.             {
  1135.                 ServitorInstance summon = (ServitorInstance) target;
  1136.                 summon.setLifeTimeRemaining(summon.getLifeTimeRemaining() - summon.getLifeTime());
  1137.                 player.sendPacket(new SetSummonRemainTime(summon.getLifeTime(), summon.getLifeTimeRemaining()));
  1138.             }
  1139.             else if (DEBUG)
  1140.             {
  1141.                 throw new RuntimeException();
  1142.             }
  1143.         }
  1144.     }
  1145.    
  1146.     @Override
  1147.     public String onAdvEvent(String event, Npc npc, PlayerInstance player)
  1148.     {
  1149.         if (DEBUG)
  1150.         {
  1151.             System.out.println(getScriptName() + "#onAdvEvent('" + event + "'," + (npc == null ? "NULL" : npc.getId() + npc.getName()) + "," + (player == null ? "NULL" : player.getName()) + ")");
  1152.         }
  1153.         QuestState st = player.getQuestState(QUEST_LOADING_INFO);
  1154.         String[] eventSplit = event.split(" ", 4);
  1155.         if (eventSplit.length != 4)
  1156.         {
  1157.             player.sendPacket(SystemMessageId.INCORRECT_NAME_PLEASE_TRY_AGAIN);
  1158.             return null;
  1159.         }
  1160.         String eventParam0 = eventSplit[0];
  1161.         String eventParam1 = eventSplit[1];
  1162.         String eventParam2 = eventSplit[2];
  1163.         String eventParam3 = eventSplit[3];
  1164.        
  1165.         switch (eventParam0)
  1166.         {
  1167.             case "reloadscript":
  1168.                 if (eventParam1.equals("1"))
  1169.                 {
  1170.                     return reloadConfig(st);
  1171.                 }
  1172.                 if (eventParam1.equals("0"))
  1173.                 {
  1174.                     return rebuildMainHtml(st);
  1175.                 }
  1176.                 if (DEBUG)
  1177.                 {
  1178.                     throw new RuntimeException();
  1179.                 }
  1180.                
  1181.             case "redirect":
  1182.                 switch (eventParam1)
  1183.                 {
  1184.                     case "main":
  1185.                         return rebuildMainHtml(st);
  1186.                     case "manage_buffs":
  1187.                         return viewAllBuffTypes();
  1188.                     case "view_buffs":
  1189.                         return buildHtml("buff");
  1190.                     case "view_resists":
  1191.                         return buildHtml("resist");
  1192.                     case "view_songs":
  1193.                         return buildHtml("song");
  1194.                     case "view_dances":
  1195.                         return buildHtml("dance");
  1196.                     case "view_chants":
  1197.                         return buildHtml("chant");
  1198.                     case "view_others":
  1199.                         return buildHtml("others");
  1200.                     case "view_special":
  1201.                         return buildHtml("special");
  1202.                     case "view_cubic":
  1203.                         return buildHtml("cubic");
  1204.                     default:
  1205.                         if (DEBUG)
  1206.                         {
  1207.                             throw new RuntimeException();
  1208.                         }
  1209.                 }
  1210.                
  1211.             case "buffpet":
  1212.                 if ((int) (System.currentTimeMillis() / 1000) > st.getInt("blockUntilTime"))
  1213.                 {
  1214.                     st.set("Pet-On-Off", eventParam1);
  1215.                     if (TIME_OUT)
  1216.                     {
  1217.                         addTimeout(st, 3, TIME_OUT_TIME / 2, 600);
  1218.                     }
  1219.                 }
  1220.                 return rebuildMainHtml(st);
  1221.            
  1222.             case "create":
  1223.             {
  1224.                 String param = eventParam1.replaceAll("[ !" + "\"" + "#$%&'()*+,/:;<=>?@" + "\\[" + "\\\\" + "\\]" + "\\^" + "`{|}~]", "");
  1225.                 if ((param.length() == 0) || param.equals("no_name"))
  1226.                 {
  1227.                     player.sendPacket(SystemMessageId.INCORRECT_NAME_PLEASE_TRY_AGAIN);
  1228.                     return showText(st, "Info", "Please, enter the scheme name!", true, "Return", "main");
  1229.                 }
  1230.                 try (Connection con = DatabaseFactory.getConnection())
  1231.                 {
  1232.                     PreparedStatement ins = con.prepareStatement("INSERT INTO npcbuffer_scheme_list (player_id,scheme_name) VALUES (?,?)");
  1233.                     ins.setInt(1, player.getObjectId());
  1234.                     ins.setString(2, param);
  1235.                     ins.executeUpdate();
  1236.                     ins.close();
  1237.                 }
  1238.                 catch (SQLException e)
  1239.                 {
  1240.                     print(e);
  1241.                 }
  1242.                 return rebuildMainHtml(st);
  1243.             }
  1244.            
  1245.             case "delete":
  1246.                 try (Connection con = DatabaseFactory.getConnection())
  1247.                 {
  1248.                     PreparedStatement rem;
  1249.                     rem = con.prepareStatement("DELETE FROM npcbuffer_scheme_list WHERE id=? LIMIT 1");
  1250.                     rem.setString(1, eventParam1);
  1251.                     rem.executeUpdate();
  1252.                     rem.close();
  1253.                     rem = con.prepareStatement("DELETE FROM npcbuffer_scheme_contents WHERE scheme_id=?");
  1254.                     rem.setString(1, eventParam1);
  1255.                     rem.executeUpdate();
  1256.                     rem.close();
  1257.                 }
  1258.                 catch (SQLException e)
  1259.                 {
  1260.                     print(e);
  1261.                 }
  1262.                 return rebuildMainHtml(st);
  1263.            
  1264.             case "delete_c":
  1265.                 return "<html><head><title>" + TITLE_NAME + "</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>Do you really want to delete '" + eventParam2 + "' scheme?<br><br>" + "<button value=\"Yes\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " delete " + eventParam1 + " x x\" width=50 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + "<button value=\"No\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " delete_1 x x x\" width=50 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + "<br><font color=303030>" + TITLE_NAME + "</font></center></body></html>";
  1266.            
  1267.             case "create_1":
  1268.                 return createScheme();
  1269.             case "edit_1":
  1270.                 return editScheme(player);
  1271.             case "delete_1":
  1272.                 return deleteScheme(player);
  1273.             case "manage_scheme_1":
  1274.                 return viewAllSchemeBuffs(eventParam1, eventParam2, "add");
  1275.             case "manage_scheme_2":
  1276.                 return viewAllSchemeBuffs(eventParam1, eventParam2, "remove");
  1277.             case "manage_scheme_select":
  1278.                 return getOptionList(eventParam1);
  1279.            
  1280.             case "remove_buff":
  1281.             {
  1282.                 String[] split = eventParam1.split("_");
  1283.                 String scheme = split[0];
  1284.                 String skill = split[1];
  1285.                 String level = split[2];
  1286.                 try (Connection con = DatabaseFactory.getConnection())
  1287.                 {
  1288.                     PreparedStatement rem = con.prepareStatement("DELETE FROM npcbuffer_scheme_contents WHERE scheme_id=? AND skill_id=? AND skill_level=? LIMIT 1");
  1289.                     rem.setString(1, scheme);
  1290.                     rem.setString(2, skill);
  1291.                     rem.setString(3, level);
  1292.                     rem.executeUpdate();
  1293.                 }
  1294.                 catch (SQLException e)
  1295.                 {
  1296.                     print(e);
  1297.                 }
  1298.                 int temp = Integer.parseInt(eventParam3) - 1;
  1299.                 final String HTML;
  1300.                 if (temp <= 0)
  1301.                 {
  1302.                     HTML = getOptionList(scheme);
  1303.                 }
  1304.                 else
  1305.                 {
  1306.                     HTML = viewAllSchemeBuffs(scheme, eventParam2, "remove");
  1307.                 }
  1308.                 return HTML;
  1309.             }
  1310.            
  1311.             case "add_buff":
  1312.             {
  1313.                 String[] split = eventParam1.split("_");
  1314.                 String scheme = split[0];
  1315.                 String skill = split[1];
  1316.                 String level = split[2];
  1317.                 int idbuffclass = getClassBuff(skill);
  1318.                 try (Connection con = DatabaseFactory.getConnection())
  1319.                 {
  1320.                     PreparedStatement ins = con.prepareStatement("INSERT INTO npcbuffer_scheme_contents (scheme_id,skill_id,skill_level,buff_class) VALUES (?,?,?,?)");
  1321.                     ins.setString(1, scheme);
  1322.                     ins.setString(2, skill);
  1323.                     ins.setString(3, level);
  1324.                     ins.setInt(4, idbuffclass);
  1325.                     ins.executeUpdate();
  1326.                     ins.close();
  1327.                 }
  1328.                 catch (SQLException e)
  1329.                 {
  1330.                     print(e);
  1331.                 }
  1332.                 int temp = Integer.parseInt(eventParam3) + 1;
  1333.                 final String HTML;
  1334.                 if (temp >= (MAX_SCHEME_BUFFS + MAX_SCHEME_DANCES))
  1335.                 {
  1336.                     HTML = getOptionList(scheme);
  1337.                 }
  1338.                 else
  1339.                 {
  1340.                     HTML = viewAllSchemeBuffs(scheme, eventParam2, "add");
  1341.                 }
  1342.                 return HTML;
  1343.             }
  1344.            
  1345.             case "edit_buff_list":
  1346.                 return viewAllBuffs(eventParam1, eventParam2, eventParam3);
  1347.            
  1348.             case "changeBuffSet":
  1349.                 if (eventParam2.equals(SET_FIGHTER))
  1350.                 {
  1351.                     eventParam2 = "0";
  1352.                 }
  1353.                 else if (eventParam2.equals(SET_MAGE))
  1354.                 {
  1355.                     eventParam2 = "1";
  1356.                 }
  1357.                 else if (eventParam2.equals(SET_ALL))
  1358.                 {
  1359.                     eventParam2 = "2";
  1360.                 }
  1361.                 else if (eventParam2.equals(SET_NONE))
  1362.                 {
  1363.                     eventParam2 = "3";
  1364.                 }
  1365.                 else if (DEBUG)
  1366.                 {
  1367.                     throw new RuntimeException();
  1368.                 }
  1369.                 return manageSelectedSet(eventParam1, eventParam2, eventParam3);
  1370.            
  1371.             case "editSelectedBuff":
  1372.             {
  1373.                 eventParam2 = eventParam2.replace("-", " ");
  1374.                 String[] split = eventParam2.split(" ");
  1375.                 String action = split[0];
  1376.                 String page = split[1];
  1377.                 manageSelectedBuff(eventParam1, action);
  1378.                 final String typeName;
  1379.                 switch (eventParam3)
  1380.                 {
  1381.                     case "buff":
  1382.                         typeName = "Buffs";
  1383.                         break;
  1384.                     case "resist":
  1385.                         typeName = "Resists";
  1386.                         break;
  1387.                     case "song":
  1388.                         typeName = "Songs";
  1389.                         break;
  1390.                     case "dance":
  1391.                         typeName = "Dances";
  1392.                         break;
  1393.                     case "chant":
  1394.                         typeName = "Chants";
  1395.                         break;
  1396.                     case "others":
  1397.                         typeName = "Others_Buffs";
  1398.                         break;
  1399.                     case "special":
  1400.                         typeName = "Special_Buffs";
  1401.                         break;
  1402.                     case "cubic":
  1403.                         typeName = "Cubics";
  1404.                         break;
  1405.                     default:
  1406.                         throw new RuntimeException();
  1407.                 }
  1408.                 return viewAllBuffs(eventParam3, typeName, page);
  1409.             }
  1410.            
  1411.             case "viewSelectedConfig":
  1412.                 throw new RuntimeException();
  1413.            
  1414.             case "changeConfig":
  1415.                 throw new RuntimeException();
  1416.            
  1417.             case "heal":
  1418.                 if ((int) (System.currentTimeMillis() / 1000) > st.getInt("blockUntilTime"))
  1419.                 {
  1420.                     if (st.getQuestItemsCount(CONSUMABLE_ID) < HEAL_PRICE)
  1421.                     {
  1422.                         return showText(st, "Sorry", "You don't have the enough items:<br>You need: <font color=LEVEL>" + HEAL_PRICE + " " + getItemNameHtml(st, CONSUMABLE_ID) + "!", false, "0", "0");
  1423.                     }
  1424.                     final boolean getSummonbuff = isPetBuff(st);
  1425.                     if (getSummonbuff)
  1426.                     {
  1427.                         if (player.getSummon() != null)
  1428.                         {
  1429.                             heal(player, getSummonbuff);
  1430.                         }
  1431.                         else
  1432.                         {
  1433.                             return showText(st, "Info", "You can't use the Pet's options.<br>Summon your pet first!", false, "Return", "main");
  1434.                         }
  1435.                     }
  1436.                     else
  1437.                     {
  1438.                         heal(player, getSummonbuff);
  1439.                     }
  1440.                     st.takeItems(CONSUMABLE_ID, HEAL_PRICE);
  1441.                     if (TIME_OUT)
  1442.                     {
  1443.                         addTimeout(st, 1, TIME_OUT_TIME / 2, 600);
  1444.                     }
  1445.                 }
  1446.                 return SMART_WINDOW ? null : rebuildMainHtml(st);
  1447.            
  1448.             case "removeBuffs":
  1449.                 if ((int) (System.currentTimeMillis() / 1000) > st.getInt("blockUntilTime"))
  1450.                 {
  1451.                     if (st.getQuestItemsCount(CONSUMABLE_ID) < BUFF_REMOVE_PRICE)
  1452.                     {
  1453.                         return showText(st, "Sorry", "You don't have the enough items:<br>You need: <font color=LEVEL>" + BUFF_REMOVE_PRICE + " " + getItemNameHtml(st, CONSUMABLE_ID) + "!", false, "0", "0");
  1454.                     }
  1455.                     final boolean getSummonbuff = isPetBuff(st);
  1456.                     if (getSummonbuff)
  1457.                     {
  1458.                         if (player.getSummon() != null)
  1459.                         {
  1460.                             player.getSummon().stopAllEffects();
  1461.                         }
  1462.                         else
  1463.                         {
  1464.                             return showText(st, "Info", "You can't use the Pet's options.<br>Summon your pet first!", false, "Return", "main");
  1465.                         }
  1466.                     }
  1467.                     else
  1468.                     {
  1469.                         player.stopAllEffects();
  1470.                         if (player.getCubics() != null)
  1471.                         {
  1472.                             for (CubicInstance cubic : player.getCubics().values())
  1473.                             {
  1474.                                 cubic.stopAction();
  1475.                                 player.getCubics().remove(cubic);
  1476.                             }
  1477.                         }
  1478.                     }
  1479.                     st.takeItems(CONSUMABLE_ID, BUFF_REMOVE_PRICE);
  1480.                     if (TIME_OUT)
  1481.                     {
  1482.                         addTimeout(st, 2, TIME_OUT_TIME / 2, 600);
  1483.                     }
  1484.                 }
  1485.                 return SMART_WINDOW ? null : rebuildMainHtml(st);
  1486.            
  1487.             case "cast":
  1488.                 if ((int) (System.currentTimeMillis() / 1000) > st.getInt("blockUntilTime"))
  1489.                 {
  1490.                     List<Integer> buffs = new ArrayList<>();
  1491.                     List<Integer> levels = new ArrayList<>();
  1492.                     try (Connection con = DatabaseFactory.getConnection())
  1493.                     {
  1494.                         PreparedStatement rss = con.prepareStatement("SELECT * FROM npcbuffer_scheme_contents WHERE scheme_id=? ORDER BY id");
  1495.                         rss.setString(1, eventParam1);
  1496.                         ResultSet action = rss.executeQuery();
  1497.                         while (action.next())
  1498.                         {
  1499.                             int id = Integer.parseInt(action.getString("skill_id"));
  1500.                             int level = Integer.parseInt(action.getString("skill_level"));
  1501.                             switch (getBuffType(id))
  1502.                             {
  1503.                                 case "buff":
  1504.                                     if (ENABLE_BUFFS)
  1505.                                     {
  1506.                                         if (isEnabled(id, level))
  1507.                                         {
  1508.                                             buffs.add(id);
  1509.                                             levels.add(level);
  1510.                                         }
  1511.                                     }
  1512.                                     break;
  1513.                                 case "resist":
  1514.                                     if (ENABLE_RESIST)
  1515.                                     {
  1516.                                         if (isEnabled(id, level))
  1517.                                         {
  1518.                                             buffs.add(id);
  1519.                                             levels.add(level);
  1520.                                         }
  1521.                                     }
  1522.                                     break;
  1523.                                 case "song":
  1524.                                     if (ENABLE_SONGS)
  1525.                                     {
  1526.                                         if (isEnabled(id, level))
  1527.                                         {
  1528.                                             buffs.add(id);
  1529.                                             levels.add(level);
  1530.                                         }
  1531.                                     }
  1532.                                     break;
  1533.                                 case "dance":
  1534.                                     if (ENABLE_DANCES)
  1535.                                     {
  1536.                                         if (isEnabled(id, level))
  1537.                                         {
  1538.                                             buffs.add(id);
  1539.                                             levels.add(level);
  1540.                                         }
  1541.                                     }
  1542.                                     break;
  1543.                                 case "chant":
  1544.                                     if (ENABLE_CHANTS)
  1545.                                     {
  1546.                                         if (isEnabled(id, level))
  1547.                                         {
  1548.                                             buffs.add(id);
  1549.                                             levels.add(level);
  1550.                                         }
  1551.                                     }
  1552.                                     break;
  1553.                                 case "others":
  1554.                                     if (ENABLE_OTHERS)
  1555.                                     {
  1556.                                         if (isEnabled(id, level))
  1557.                                         {
  1558.                                             buffs.add(id);
  1559.                                             levels.add(level);
  1560.                                         }
  1561.                                     }
  1562.                                     break;
  1563.                                 case "special":
  1564.                                     if (ENABLE_SPECIAL)
  1565.                                     {
  1566.                                         if (isEnabled(id, level))
  1567.                                         {
  1568.                                             buffs.add(id);
  1569.                                             levels.add(level);
  1570.                                         }
  1571.                                     }
  1572.                                     break;
  1573.                                 default:
  1574.                                     if (DEBUG)
  1575.                                     {
  1576.                                         throw new RuntimeException();
  1577.                                     }
  1578.                             }
  1579.                         }
  1580.                     }
  1581.                     catch (SQLException e)
  1582.                     {
  1583.                         print(e);
  1584.                     }
  1585.                    
  1586.                     if (buffs.size() == 0)
  1587.                     {
  1588.                         return viewAllSchemeBuffs(eventParam1, "1", "add");
  1589.                     }
  1590.                     if (!FREE_BUFFS)
  1591.                     {
  1592.                         if (st.getQuestItemsCount(CONSUMABLE_ID) < SCHEME_BUFF_PRICE)
  1593.                         {
  1594.                             return showText(st, "Sorry", "You don't have the enough items:<br>You need: <font color=LEVEL>" + SCHEME_BUFF_PRICE + " " + getItemNameHtml(st, CONSUMABLE_ID) + "!", false, "0", "0");
  1595.                         }
  1596.                     }
  1597.                    
  1598.                     final boolean getSummonbuff = isPetBuff(st);
  1599.                     for (int i = 0; i < buffs.size(); ++i)
  1600.                     {
  1601.                         if (!getSummonbuff)
  1602.                         {
  1603.                             SkillData.getInstance().getSkill(buffs.get(i), levels.get(i)).applyEffects(player, player);
  1604.                         }
  1605.                         else
  1606.                         {
  1607.                             if (player.getSummon() != null)
  1608.                             {
  1609.                                 SkillData.getInstance().getSkill(buffs.get(i), levels.get(i)).applyEffects(player.getSummon(), player.getSummon());
  1610.                             }
  1611.                             else
  1612.                             {
  1613.                                 return showText(st, "Info", "You can't use the Pet's options.<br>Summon your pet first!", false, "Return", "main");
  1614.                             }
  1615.                         }
  1616.                     }
  1617.                     st.takeItems(CONSUMABLE_ID, SCHEME_BUFF_PRICE);
  1618.                     if (TIME_OUT)
  1619.                     {
  1620.                         addTimeout(st, 3, TIME_OUT_TIME, 600);
  1621.                     }
  1622.                 }
  1623.                 return SMART_WINDOW ? null : rebuildMainHtml(st);
  1624.            
  1625.             case "giveBuffs":
  1626.             {
  1627.                 final int cost;
  1628.                 switch (eventParam3)
  1629.                 {
  1630.                     case "buff":
  1631.                         cost = BUFF_PRICE;
  1632.                         break;
  1633.                     case "resist":
  1634.                         cost = RESIST_PRICE;
  1635.                         break;
  1636.                     case "song":
  1637.                         cost = SONG_PRICE;
  1638.                         break;
  1639.                     case "dance":
  1640.                         cost = DANCE_PRICE;
  1641.                         break;
  1642.                     case "chant":
  1643.                         cost = CHANT_PRICE;
  1644.                         break;
  1645.                     case "others":
  1646.                         cost = OTHERS_PRICE;
  1647.                         break;
  1648.                     case "special":
  1649.                         cost = SPECIAL_PRICE;
  1650.                         break;
  1651.                     case "cubic":
  1652.                         cost = CUBIC_PRICE;
  1653.                         break;
  1654.                     default:
  1655.                         throw new RuntimeException();
  1656.                 }
  1657.                
  1658.                 if ((int) (System.currentTimeMillis() / 1000) > st.getInt("blockUntilTime"))
  1659.                 {
  1660.                     if (!FREE_BUFFS)
  1661.                     {
  1662.                         if (st.getQuestItemsCount(CONSUMABLE_ID) < cost)
  1663.                         {
  1664.                             return showText(st, "Sorry", "You don't have the enough items:<br>You need: <font color=LEVEL>" + cost + " " + getItemNameHtml(st, CONSUMABLE_ID) + "!", false, "0", "0");
  1665.                         }
  1666.                     }
  1667.                     Skill skill = SkillData.getInstance().getSkill(Integer.parseInt(eventParam1), Integer.parseInt(eventParam2));
  1668.                     if (skill.hasEffectType(EffectType.SUMMON))
  1669.                     {
  1670.                         if (st.getQuestItemsCount(skill.getItemConsumeId()) < skill.getItemConsumeCount())
  1671.                         {
  1672.                             return showText(st, "Sorry", "You don't have the enough items:<br>You need: <font color=LEVEL>" + skill.getItemConsumeCount() + " " + getItemNameHtml(st, skill.getItemConsumeId()) + "!", false, "0", "0");
  1673.                         }
  1674.                     }
  1675.                     final boolean getSummonbuff = isPetBuff(st);
  1676.                     if (!getSummonbuff)
  1677.                     {
  1678.                         if (eventParam3.equals("cubic"))
  1679.                         {
  1680.                             if (player.getCubics() != null)
  1681.                             {
  1682.                                 for (CubicInstance cubic : player.getCubics().values())
  1683.                                 {
  1684.                                     cubic.stopAction();
  1685.                                     player.getCubics().remove(cubic);
  1686.                                 }
  1687.                             }
  1688.                             player.useMagic(SkillData.getInstance().getSkill(Integer.parseInt(eventParam1), Integer.parseInt(eventParam2)), false, false);
  1689.                         }
  1690.                         else
  1691.                         {
  1692.                             SkillData.getInstance().getSkill(Integer.parseInt(eventParam1), Integer.parseInt(eventParam2)).applyEffects(player, player);
  1693.                         }
  1694.                     }
  1695.                     else
  1696.                     {
  1697.                         if (eventParam3.equals("cubic"))
  1698.                         {
  1699.                             if (player.getCubics() != null)
  1700.                             {
  1701.                                 for (CubicInstance cubic : player.getCubics().values())
  1702.                                 {
  1703.                                     cubic.stopAction();
  1704.                                     player.getCubics().remove(cubic);
  1705.                                 }
  1706.                             }
  1707.                             player.useMagic(SkillData.getInstance().getSkill(Integer.parseInt(eventParam1), Integer.parseInt(eventParam2)), false, false);
  1708.                         }
  1709.                         else
  1710.                         {
  1711.                             if (player.getSummon() != null)
  1712.                             {
  1713.                                 SkillData.getInstance().getSkill(Integer.parseInt(eventParam1), Integer.parseInt(eventParam2)).applyEffects(player.getSummon(), player.getSummon());
  1714.                             }
  1715.                             else
  1716.                             {
  1717.                                 return showText(st, "Info", "You can't use the Pet's options.<br>Summon your pet first!", false, "Return", "main");
  1718.                             }
  1719.                         }
  1720.                     }
  1721.                     st.takeItems(CONSUMABLE_ID, cost);
  1722.                     if (TIME_OUT)
  1723.                     {
  1724.                         addTimeout(st, 3, TIME_OUT_TIME / 10, 600);
  1725.                     }
  1726.                 }
  1727.                 return SMART_WINDOW ? null : buildHtml(eventParam3);
  1728.             }
  1729.            
  1730.             case "castBuffSet":
  1731.                 if ((int) (System.currentTimeMillis() / 1000) > st.getInt("blockUntilTime"))
  1732.                 {
  1733.                     if (!FREE_BUFFS)
  1734.                     {
  1735.                         if (st.getQuestItemsCount(CONSUMABLE_ID) < BUFF_SET_PRICE)
  1736.                         {
  1737.                             return showText(st, "Sorry", "You don't have the enough items:<br>You need: <font color=LEVEL>" + BUFF_SET_PRICE + " " + getItemNameHtml(st, CONSUMABLE_ID) + "!", false, "0", "0");
  1738.                         }
  1739.                     }
  1740.                     List<int[]> buff_sets = new ArrayList<>();
  1741.                     final int player_class;
  1742.                     if (player.isMageClass())
  1743.                     {
  1744.                         player_class = 1;
  1745.                     }
  1746.                     else
  1747.                     {
  1748.                         player_class = 0;
  1749.                     }
  1750.                     final boolean getSummonbuff = isPetBuff(st);
  1751.                     if (!getSummonbuff)
  1752.                     {
  1753.                         try (Connection con = DatabaseFactory.getConnection())
  1754.                         {
  1755.                             PreparedStatement getSimilarNameCount = con.prepareStatement("SELECT buffId,buffLevel FROM npcbuffer_buff_list WHERE forClass IN (?,?) ORDER BY id ASC");
  1756.                             getSimilarNameCount.setInt(1, player_class);
  1757.                             getSimilarNameCount.setString(2, "2");
  1758.                             ResultSet rss = getSimilarNameCount.executeQuery();
  1759.                             while (rss.next())
  1760.                             {
  1761.                                 int id = rss.getInt("buffId");
  1762.                                 int lvl = rss.getInt("buffLevel");
  1763.                                 buff_sets.add(new int[]
  1764.                                 {
  1765.                                     id,
  1766.                                     lvl
  1767.                                 });
  1768.                             }
  1769.                         }
  1770.                         catch (SQLException e)
  1771.                         {
  1772.                             print(e);
  1773.                         }
  1774.                         for (int[] i : buff_sets)
  1775.                         {
  1776.                             SkillData.getInstance().getSkill(i[0], i[1]).applyEffects(player, player);
  1777.                         }
  1778.                     }
  1779.                     else
  1780.                     {
  1781.                         if (player.getSummon() != null)
  1782.                         {
  1783.                             try (Connection con = DatabaseFactory.getConnection())
  1784.                             {
  1785.                                 PreparedStatement getSimilarNameCount = con.prepareStatement("SELECT buffId,buffLevel FROM npcbuffer_buff_list WHERE forClass IN (?,?) ORDER BY id ASC");
  1786.                                 getSimilarNameCount.setString(1, "0");
  1787.                                 getSimilarNameCount.setString(2, "2");
  1788.                                 ResultSet rss = getSimilarNameCount.executeQuery();
  1789.                                 while (rss.next())
  1790.                                 {
  1791.                                     int id = rss.getInt("buffId");
  1792.                                     int lvl = rss.getInt("buffLevel");
  1793.                                     buff_sets.add(new int[]
  1794.                                     {
  1795.                                         id,
  1796.                                         lvl
  1797.                                     });
  1798.                                 }
  1799.                             }
  1800.                             catch (SQLException e)
  1801.                             {
  1802.                                 print(e);
  1803.                             }
  1804.                             for (int[] i : buff_sets)
  1805.                             {
  1806.                                 SkillData.getInstance().getSkill(i[0], i[1]).applyEffects(player.getSummon(), player.getSummon());
  1807.                             }
  1808.                         }
  1809.                         else
  1810.                         {
  1811.                             return showText(st, "Info", "You can't use the Pet's options.<br>Summon your pet first!", false, "Return", "main");
  1812.                         }
  1813.                     }
  1814.                     st.takeItems(CONSUMABLE_ID, BUFF_SET_PRICE);
  1815.                     if (TIME_OUT)
  1816.                     {
  1817.                         addTimeout(st, 3, TIME_OUT_TIME, 600);
  1818.                     }
  1819.                 }
  1820.                 return SMART_WINDOW ? null : rebuildMainHtml(st);
  1821.            
  1822.         }
  1823.         return rebuildMainHtml(st);
  1824.     }
  1825.    
  1826.     @Override
  1827.     public String onFirstTalk(Npc npc, PlayerInstance player)
  1828.     {
  1829.         QuestState st = player.getQuestState(QUEST_LOADING_INFO);
  1830.         if (st == null)
  1831.         {
  1832.             st = newQuestState(player);
  1833.         }
  1834.         if (player.isGM())
  1835.         {
  1836.             if (SCRIPT_RELOAD)
  1837.             {
  1838.                 return reloadPanel(st);
  1839.             }
  1840.             return rebuildMainHtml(st);
  1841.         }
  1842.         else if ((int) (System.currentTimeMillis() / 1000) > st.getInt("blockUntilTime"))
  1843.         {
  1844.             return showText(st, "Sorry", "You have to wait a while!<br>if you wish to use my services!", false, "Return", "main");
  1845.         }
  1846.         if (!BUFF_WITH_KARMA && (player.getKarma() > 0))
  1847.         {
  1848.             return showText(st, "Info", "You have too much <font color=FF0000>karma!</font><br>Come back,<br>when you don't have any karma!", false, "Return", "main");
  1849.         }
  1850.         else if (OlympiadManager.getInstance().isRegistered(player))
  1851.         {
  1852.             return showText(st, "Info", "You can not buff while you are in <font color=FF0000>Olympiad!</font><br>Come back,<br>when you are out of the Olympiad.", false, "Return", "main");
  1853.         }
  1854.         else if (TvTEvent.isPlayerParticipant(player.getObjectId()))
  1855.         {
  1856.             return showText(st, "Info", "You can not buff while you are in <font color=\"FF0000\">TvT!</font><br>Come back,<br>when you are out of TvT!", false, "Return", "main");
  1857.         }
  1858.         else if (player.getLevel() < MIN_LEVEL)
  1859.         {
  1860.             return showText(st, "Info", "Your level is too low!<br>You have to be at least level <font color=LEVEL>" + MIN_LEVEL + "</font>,<br>to use my services!", false, "Return", "main");
  1861.         }
  1862.         else if (player.getPvpFlag() > 0)
  1863.         {
  1864.             return showText(st, "Info", "You can't buff while you are <font color=800080>flagged!</font><br>Wait some time and try again!", false, "Return", "main");
  1865.         }
  1866.         else if (player.isInCombat())
  1867.         {
  1868.             return showText(st, "Info", "You can't buff while you are attacking!<br>Stop your fight and try again!", false, "Return", "main");
  1869.         }
  1870.         else
  1871.         {
  1872.             return rebuildMainHtml(st);
  1873.         }
  1874.     }
  1875.    
  1876.     @Override
  1877.     public boolean showResult(PlayerInstance player, String res)
  1878.     {
  1879.         if (SMART_WINDOW)
  1880.         {
  1881.             if ((player != null) && (res != null) && res.startsWith("<html>"))
  1882.             {
  1883.                 final NpcHtmlMessage npcReply = new NpcHtmlMessage();
  1884.                 npcReply.setHtml(res);
  1885.                 player.sendPacket(npcReply);
  1886.                 player.sendPacket(ActionFailed.STATIC_PACKET);
  1887.                 return false;
  1888.             }
  1889.         }
  1890.         return super.showResult(player, res);
  1891.     }
  1892.    
  1893.     private String getSkillIconHtml(int id, int level)
  1894.     {
  1895.         String iconNumber = getSkillIconNumber(id, level);
  1896.         return "<button action=\"bypass -h Quest " + QUEST_LOADING_INFO + " description " + id + " " + level + " x\" width=32 height=32 back=\"Icon.skill" + iconNumber + "\" fore=\"Icon.skill" + iconNumber + "\">";
  1897.     }
  1898.    
  1899.     private String getSkillIconNumber(int id, int level)
  1900.     {
  1901.         String formato;
  1902.         if (id == 4)
  1903.         {
  1904.             formato = "0004";
  1905.         }
  1906.         else if ((id > 9) && (id < 100))
  1907.         {
  1908.             formato = "00" + id;
  1909.         }
  1910.         else if ((id > 99) && (id < 1000))
  1911.         {
  1912.             formato = "0" + id;
  1913.         }
  1914.         else if (id == 1517)
  1915.         {
  1916.             formato = "1536";
  1917.         }
  1918.         else if (id == 1518)
  1919.         {
  1920.             formato = "1537";
  1921.         }
  1922.         else if (id == 1547)
  1923.         {
  1924.             formato = "0065";
  1925.         }
  1926.         else if (id == 2076)
  1927.         {
  1928.             formato = "0195";
  1929.         }
  1930.         else if ((id > 4550) && (id < 4555))
  1931.         {
  1932.             formato = "5739";
  1933.         }
  1934.         else if ((id > 4698) && (id < 4701))
  1935.         {
  1936.             formato = "1331";
  1937.         }
  1938.         else if ((id > 4701) && (id < 4704))
  1939.         {
  1940.             formato = "1332";
  1941.         }
  1942.         else if (id == 6049)
  1943.         {
  1944.             formato = "0094";
  1945.         }
  1946.         else
  1947.         {
  1948.             formato = String.valueOf(id);
  1949.         }
  1950.         return formato;
  1951.     }
  1952.    
  1953.     static public void main(String[] args)
  1954.     {
  1955.         new NpcBuffer();
  1956.     }
  1957. }
  1958. [/code]
  1959. NpcBuffer.ini
  1960. [code]
  1961. # ---------------------------------------------------------------------------
  1962. # Npc Buffer Config By Gremlin
  1963. # ---------------------------------------------------------------------------
  1964.  
  1965. # Select the NPC Buffer Id
  1966. # Default: 12
  1967. NpcBufferId = 12
  1968.  
  1969. # Enable Buff Section?
  1970. # Default: False
  1971. EnableBuffSection = True
  1972.  
  1973. # Enable Scheme System?
  1974. # Default: False
  1975. EnableSchemeSystem = True
  1976.  
  1977. # Enable Buffer Heal?
  1978. # Default: False
  1979. EnableBufferHeal = True
  1980.  
  1981. # Here you can activate or deactivate more settings
  1982. # Default: False
  1983. EnableProphetBuffs = True
  1984. EnableResistBuffs = True
  1985. EnableSongsBuffs = True
  1986. EnableDanceBuffs = True
  1987. EnableChantsBuffs = True
  1988. EnableOthersBuffs = True
  1989. EnableSpecialBuffs = True
  1990. EnableCubics = True
  1991.  
  1992. # Allow removing buffs?
  1993. # Default: False
  1994. EnableRemoveBuffs = True
  1995.  
  1996. # Allow auto buffs?
  1997. # Default: False
  1998. EnableSetBuffs = True
  1999.  
  2000. # Allow NPC Buffer for player with karma?
  2001. # Default: False
  2002. NpcBufferWithKarma = True
  2003.  
  2004. # Allow free buffs?
  2005. # Default: False
  2006. EnableFreeBuffs = True
  2007.  
  2008. # Here you choose the currency id and quantity to be used in the NPC Buffer
  2009. BuffPriceId = 57
  2010. BuffsPriceAmount = 1000
  2011.  
  2012. # Value for using the scheme buffs system
  2013. SchemePriceAmount = 25000
  2014.  
  2015. # Minimum level to use the NPC Buffer
  2016. # Default: 20
  2017. MinLvlForBuffs = 20
  2018.  
  2019. # Select the number of schemes allowed per character
  2020. # Default: 4
  2021. MaxScheme = 4
  2022.  
  2023. # Select the maximum number of buffers per scheme
  2024. # Default: 24
  2025. MaxNormalBuffs = 24
  2026. MaxDancesAndSongs = 12
  2027.  
  2028. # Choose a title for the npc buffer's HTML
  2029. # Default: Npc Buffer
  2030. NpcTitle = Npc Buffer
  2031. [/code]
  2032. Config.java
  2033. [code] 
  2034.     private static final String CUSTOM_WEDDING_CONFIG_FILE = "./config/Custom/Wedding.ini";
  2035.     private static final String CUSTOM_WALKER_BOT_PROTECTION_CONFIG_FILE = "./config/Custom/WalkerBotProtection.ini";
  2036. +   private static final String CUSTOM_NPCBUFFER_CONFIG_FILE = "./config/Custom/NpcBuffer.ini";
  2037. ==================================
  2038. +   // Npc Buffer
  2039. +   public static String NPC_BUFFER_TITLE;
  2040. +   public static boolean ENABLE_BUFF_SECTION;
  2041. +   public static boolean ENABLE_SCHEME_SYSTEM;
  2042. +   public static boolean ENABLE_NPC_BUFFER_HEAL;
  2043. +   public static boolean ENABLE_NPC_BUFFER_BUFFS;
  2044. +   public static boolean ENABLE_NPC_BUFFER_RESIST;
  2045. +   public static boolean ENABLE_NPC_BUFFER_SONG;
  2046. +   public static boolean ENABLE_NPC_BUFFER_DANCE;
  2047. +   public static boolean ENABLE_NPC_BUFFER_CHANT;
  2048. +   public static boolean ENABLE_NPC_BUFFER_OTHERS;
  2049. +   public static boolean ENABLE_NPC_BUFFER_SPECIAL;
  2050. +   public static boolean ENABLE_NPC_BUFFER_CUBIC;
  2051. +   public static boolean ENABLE_NPC_BUFFER_REMOVE;
  2052. +   public static boolean ENABLE_NPC_BUFFER_SET;
  2053. +   public static boolean ENABLE_NPC_BUFFER_WITH_KARMA;
  2054. +   public static boolean ENABLE_NPC_BUFFER_FREE;
  2055. +   public static int NPC_BUFFER_PRICE;
  2056. +   public static int NPC_BUFFER_MIN_LVL;
  2057. +   public static int NPC_BUFF_PRICE_SCHEME;
  2058. +   public static int NPC_BUFFER_ID_ITEM;
  2059. +   public static int NPC_BUFF_MAX_SCHEME;
  2060. +   public static int NPC_BUFF_MAX_BUFFS;
  2061. +   public static int NPC_BUFF_MAX_DANCES_SONGS;
  2062. +   public static int NPC_BUFF_NPCID;
  2063.    
  2064.     /**
  2065.      * This class initializes all global variables for configuration.<br>
  2066.      * If the key doesn't appear in config file, a default value is set by this class. {@link #SERVER_CONFIG_FILE} (config file) for configuring your server.
  2067.      * @param serverMode
  2068.      */
  2069.     public static void load(ServerMode serverMode)
  2070.  
  2071. =====================================
  2072. +           // Load Npc Buffer Config file (if exists)
  2073. +           final PropertiesParser NpcBuffer = new PropertiesParser(CUSTOM_NPCBUFFER_CONFIG_FILE);
  2074. +          
  2075. +           NPC_BUFFER_TITLE = NpcBuffer.getString("NpcTitle", "Npc Buffer By Gremlin");
  2076. +           ENABLE_BUFF_SECTION = NpcBuffer.getBoolean("EnableBuffSection", false);
  2077. +           ENABLE_SCHEME_SYSTEM = NpcBuffer.getBoolean("EnableSchemeSystem", false);
  2078. +           ENABLE_NPC_BUFFER_HEAL = NpcBuffer.getBoolean("EnableBufferHeal", false);
  2079. +           ENABLE_NPC_BUFFER_BUFFS = NpcBuffer.getBoolean("EnableProphetBuffs", false);
  2080. +           ENABLE_NPC_BUFFER_RESIST = NpcBuffer.getBoolean("EnableResistBuffs", false);
  2081. +           ENABLE_NPC_BUFFER_SONG = NpcBuffer.getBoolean("EnableSongsBuffs", false);
  2082. +           ENABLE_NPC_BUFFER_DANCE = NpcBuffer.getBoolean("EnableDanceBuffs", false);
  2083. +           ENABLE_NPC_BUFFER_CHANT = NpcBuffer.getBoolean("EnableChantsBuffs", false);
  2084. +           ENABLE_NPC_BUFFER_OTHERS = NpcBuffer.getBoolean("EnableOthersBuffs", false);
  2085. +           ENABLE_NPC_BUFFER_SPECIAL = NpcBuffer.getBoolean("EnableSpecialBuffs", false);
  2086. +           ENABLE_NPC_BUFFER_CUBIC = NpcBuffer.getBoolean("EnableCubics", false);
  2087. +           ENABLE_NPC_BUFFER_REMOVE = NpcBuffer.getBoolean("EnableRemoveBuffs", false);
  2088. +           ENABLE_NPC_BUFFER_SET = NpcBuffer.getBoolean("EnableSetBuffs", false);
  2089. +           ENABLE_NPC_BUFFER_WITH_KARMA = NpcBuffer.getBoolean("NpcBufferWithKarma", false);
  2090. +           ENABLE_NPC_BUFFER_FREE = NpcBuffer.getBoolean("EnableFreeBuffs", false);
  2091. +           NPC_BUFFER_PRICE = NpcBuffer.getInt("BuffsPriceAmount", 1000);
  2092. +           NPC_BUFFER_MIN_LVL = NpcBuffer.getInt("MinLvlForBuffs", 20);
  2093. +           NPC_BUFF_PRICE_SCHEME = NpcBuffer.getInt("SchemePriceAmount", 10000);
  2094. +           NPC_BUFFER_ID_ITEM = NpcBuffer.getInt("BuffPriceId", 57);
  2095. +           NPC_BUFF_MAX_SCHEME = NpcBuffer.getInt("MaxScheme", 4);
  2096. +           NPC_BUFF_MAX_BUFFS = NpcBuffer.getInt("MaxNormalBuffs", 24);
  2097. +           NPC_BUFF_MAX_DANCES_SONGS = NpcBuffer.getInt("MaxDancesAndSongs", 12);
  2098. +           NPC_BUFF_NPCID = NpcBuffer.getInt("NpcBufferId", 12);
  2099. [/code]
  2100.  
  2101.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement