Advertisement
Sarada-L2

Scheme Buff Acis Para Frozen yo:Sarada

Mar 2nd, 2021
958
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 43.17 KB | None | 0 0
  1. diff --git a/config/CustomMods/SchemeBuff.ini b/config/CustomMods/SchemeBuff.ini
  2. index e69de29..2ee26fb 100644
  3. --- a/config/CustomMods/SchemeBuff.ini
  4. +++ b/config/CustomMods/SchemeBuff.ini
  5. @@ -0,0 +1,18 @@
  6. +#=============================================================
  7. +# Buffer
  8. +#=============================================================
  9. +
  10. +# Maximum number of available schemes per player.
  11. +BufferMaxSchemesPerChar = 4
  12. +
  13. +# Static cost of buffs ; override skills price if different of -1.
  14. +BufferStaticCostPerBuff = -1
  15. +
  16. +# Price Buff Special
  17. +CoinIdPriceBuff = -1
  18. +
  19. +# Auto buffer for fighter
  20. +FighterBuffList = 4342,4357,4349,4346,1087,1062,4347,4360,4359,4358,4345,4350,4344,274,275,272,271,264,269,304,267,266,268,1389,1363,4699,1416,1323
  21. +
  22. +# Auto buffer for mage
  23. +MageBuffList = 4342,4355,4347,4351,4356,4349,4346,4350,4344,1303,276,277,273,365,269,270,304,267,268,1389,1413,4703,1416,1393,1392,1352,1353,1323
  24. \ No newline at end of file
  25. diff --git a/head-src/Dev/SpecialMods/BuffSkillHolder.java b/head-src/Dev/SpecialMods/BuffSkillHolder.java
  26. new file mode 100644
  27. index 0000000..85f4c82
  28. --- /dev/null
  29. +++ b/head-src/Dev/SpecialMods/BuffSkillHolder.java
  30. @@ -0,0 +1,28 @@
  31. +package Dev.SpecialMods;
  32. +
  33. +/**
  34. + * A container used for schemes buffer.
  35. + */
  36. +public final class BuffSkillHolder extends IntIntHolder
  37. +{
  38. + private final String _type;
  39. + private final String _description;
  40. +
  41. + public BuffSkillHolder(int id, int price, String type, String description)
  42. + {
  43. + super(id, price);
  44. +
  45. + _type = type;
  46. + _description = description;
  47. + }
  48. +
  49. + public final String getType()
  50. + {
  51. + return _type;
  52. + }
  53. +
  54. + public final String getDescription()
  55. + {
  56. + return _description;
  57. + }
  58. +}
  59. \ No newline at end of file
  60. diff --git a/head-src/Dev/SpecialMods/IntIntHolder.java b/head-src/Dev/SpecialMods/IntIntHolder.java
  61. new file mode 100644
  62. index 0000000..a01f69e
  63. --- /dev/null
  64. +++ b/head-src/Dev/SpecialMods/IntIntHolder.java
  65. @@ -0,0 +1,67 @@
  66. +/*
  67. + * This program is free software: you can redistribute it and/or modify it under
  68. + * the terms of the GNU General Public License as published by the Free Software
  69. + * Foundation, either version 3 of the License, or (at your option) any later
  70. + * version.
  71. + *
  72. + * This program is distributed in the hope that it will be useful, but WITHOUT
  73. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  74. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  75. + * details.
  76. + *
  77. + * You should have received a copy of the GNU General Public License along with
  78. + * this program. If not, see <http://www.gnu.org/licenses/>.
  79. + */
  80. +package Dev.SpecialMods;
  81. +
  82. +import com.l2jfrozen.gameserver.datatables.SkillTable;
  83. +import com.l2jfrozen.gameserver.model.L2Skill;
  84. +
  85. +/**
  86. + * A generic int/int container.
  87. + */
  88. +public class IntIntHolder
  89. +{
  90. + private int _id;
  91. + private int _value;
  92. +
  93. + public IntIntHolder(int id, int value)
  94. + {
  95. + _id = id;
  96. + _value = value;
  97. + }
  98. +
  99. + public int getId()
  100. + {
  101. + return _id;
  102. + }
  103. +
  104. + public int getValue()
  105. + {
  106. + return _value;
  107. + }
  108. +
  109. + public void setId(int id)
  110. + {
  111. + _id = id;
  112. + }
  113. +
  114. + public void setValue(int value)
  115. + {
  116. + _value = value;
  117. + }
  118. +
  119. + /**
  120. + * @return the L2Skill associated to the id/value.
  121. + */
  122. + public final L2Skill getSkill()
  123. + {
  124. + return SkillTable.getInstance().getInfo(_id, _value);
  125. + }
  126. +
  127. + @Override
  128. + public String toString()
  129. + {
  130. + return getClass().getSimpleName() + ": Id: " + _id + ", Value: " + _value;
  131. + }
  132. +}
  133. \ No newline at end of file
  134. diff --git a/head-src/Dev/SpecialMods/MathUtil.java b/head-src/Dev/SpecialMods/MathUtil.java
  135. new file mode 100644
  136. index 0000000..1a884b4
  137. --- /dev/null
  138. +++ b/head-src/Dev/SpecialMods/MathUtil.java
  139. @@ -0,0 +1,39 @@
  140. +/*
  141. + * This program is free software: you can redistribute it and/or modify it under
  142. + * the terms of the GNU General Public License as published by the Free Software
  143. + * Foundation, either version 3 of the License, or (at your option) any later
  144. + * version.
  145. + *
  146. + * This program is distributed in the hope that it will be useful, but WITHOUT
  147. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  148. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  149. + * details.
  150. + *
  151. + * You should have received a copy of the GNU General Public License along with
  152. + * this program. If not, see <http://www.gnu.org/licenses/>.
  153. + */
  154. +package Dev.SpecialMods;
  155. +
  156. +public class MathUtil
  157. +{
  158. + /**
  159. + * @param objectsSize : The overall elements size.
  160. + * @param pageSize : The number of elements per page.
  161. + * @return The number of pages, based on the number of elements and the number of elements we want per page.
  162. + */
  163. + public static int countPagesNumber(int objectsSize, int pageSize)
  164. + {
  165. + return objectsSize / pageSize + (objectsSize % pageSize == 0 ? 0 : 1);
  166. + }
  167. +
  168. + /**
  169. + * @param numToTest : The number to test.
  170. + * @param min : The minimum limit.
  171. + * @param max : The maximum limit.
  172. + * @return the number or one of the limit (mininum / maximum).
  173. + */
  174. + public static int limit(int numToTest, int min, int max)
  175. + {
  176. + return (numToTest > max) ? max : ((numToTest < min) ? min : numToTest);
  177. + }
  178. +}
  179. \ No newline at end of file
  180. diff --git a/head-src/Dev/SpecialMods/XMLDocumentFactory.java b/head-src/Dev/SpecialMods/XMLDocumentFactory.java
  181. new file mode 100644
  182. index 0000000..ebf695d
  183. --- /dev/null
  184. +++ b/head-src/Dev/SpecialMods/XMLDocumentFactory.java
  185. @@ -0,0 +1,72 @@
  186. +/*
  187. + * Copyright 2010 InC-Gaming, Patrick Biesenbach aka. Forsaiken. All rights reserved.
  188. + */
  189. +package Dev.SpecialMods;
  190. +
  191. +import java.io.File;
  192. +
  193. +import javax.xml.parsers.DocumentBuilder;
  194. +import javax.xml.parsers.DocumentBuilderFactory;
  195. +
  196. +import org.w3c.dom.Document;
  197. +
  198. +public final class XMLDocumentFactory
  199. +{
  200. + public static final XMLDocumentFactory getInstance()
  201. + {
  202. + return SingletonHolder._instance;
  203. + }
  204. +
  205. + private final DocumentBuilder _builder;
  206. +
  207. + protected XMLDocumentFactory() throws Exception
  208. + {
  209. + try
  210. + {
  211. + final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  212. + factory.setValidating(false);
  213. + factory.setIgnoringComments(true);
  214. +
  215. + _builder = factory.newDocumentBuilder();
  216. + }
  217. + catch (Exception e)
  218. + {
  219. + throw new Exception("Failed initializing", e);
  220. + }
  221. + }
  222. +
  223. + public final Document loadDocument(final String filePath) throws Exception
  224. + {
  225. + return loadDocument(new File(filePath));
  226. + }
  227. +
  228. + public final Document loadDocument(final File file) throws Exception
  229. + {
  230. + if (!file.exists() || !file.isFile())
  231. + throw new Exception("File: " + file.getAbsolutePath() + " doesn't exist and/or is not a file.");
  232. +
  233. + return _builder.parse(file);
  234. + }
  235. +
  236. + public final Document newDocument()
  237. + {
  238. + return _builder.newDocument();
  239. + }
  240. +
  241. + private static class SingletonHolder
  242. + {
  243. + protected static final XMLDocumentFactory _instance;
  244. +
  245. + static
  246. + {
  247. + try
  248. + {
  249. + _instance = new XMLDocumentFactory();
  250. + }
  251. + catch (Exception e)
  252. + {
  253. + throw new ExceptionInInitializerError(e);
  254. + }
  255. + }
  256. + }
  257. +}
  258. \ No newline at end of file
  259. diff --git a/head-src/com/l2jfrozen/Config.java b/head-src/com/l2jfrozen/Config.java
  260. index e2d04ce..36631e6 100644
  261. --- a/head-src/com/l2jfrozen/Config.java
  262. +++ b/head-src/com/l2jfrozen/Config.java
  263. @@ -51,10 +51,61 @@
  264. import com.l2jfrozen.loginserver.LoginController;
  265. import com.l2jfrozen.util.StringUtil;
  266.  
  267. +import Dev.SpecialMods.BuffSkillHolder;
  268. +
  269. public final class Config
  270. {
  271. private static final Logger LOGGER = Logger.getLogger(Config.class);
  272.  
  273. + //============================================================
  274. + /** Buffer */
  275. + public static int BUFFER_MAX_SCHEMES;
  276. + public static int BUFFER_MAX_SKILLS;
  277. + public static int BUFFER_STATIC_BUFF_COST;
  278. + public static int COIN_ITEMID;
  279. + public static String BUFFER_BUFFS;
  280. + public static Map<Integer, BuffSkillHolder> BUFFER_BUFFLIST;
  281. + /** Buffer */
  282. + public static String FIGHTER_BUFF;
  283. + public static ArrayList<Integer> FIGHTER_BUFF_LIST = new ArrayList<>();
  284. + public static String MAGE_BUFF;
  285. + public static ArrayList<Integer> MAGE_BUFF_LIST = new ArrayList<>();
  286. +
  287. + //============================================================
  288. + public static void loadSchemeBuffConfig()
  289. + {
  290. + final String FILENAME = "./config/CustomMods/SchemeBuff.ini";
  291. + try
  292. + {
  293. + Properties buffer = new Properties();
  294. + InputStream is = new FileInputStream(new File(FILENAME));
  295. + buffer.load(is);
  296. + is.close();
  297. + BUFFER_MAX_SCHEMES = Integer.parseInt(buffer.getProperty("BufferMaxSchemesPerChar", "4"));
  298. + BUFFER_STATIC_BUFF_COST = Integer.parseInt(buffer.getProperty("BufferStaticCostPerBuff", "-1"));
  299. + COIN_ITEMID = Integer.parseInt(buffer.getProperty("CoinIdPriceBuff", "-1"));
  300. + FIGHTER_BUFF = buffer.getProperty("FighterBuffList", "0");
  301. + FIGHTER_BUFF_LIST = new ArrayList<>();
  302. + for (String id : FIGHTER_BUFF.trim().split(","))
  303. + {
  304. + FIGHTER_BUFF_LIST.add(Integer.parseInt(id.trim()));
  305. + }
  306. +
  307. + MAGE_BUFF = buffer.getProperty("MageBuffList", "0");
  308. + MAGE_BUFF_LIST = new ArrayList<>();
  309. + for (String id : MAGE_BUFF.trim().split(","))
  310. + {
  311. + MAGE_BUFF_LIST.add(Integer.parseInt(id.trim()));
  312. + }
  313. +
  314. + }
  315. + catch(Exception e)
  316. + {
  317. + e.printStackTrace();
  318. + throw new Error("Failed to Load " + FILENAME + " File.");
  319. + }
  320. + }
  321. +
  322. // ============================================================
  323. public static boolean BOTS_PREVENTION;
  324. public static int KILLS_COUNTER;
  325. @@ -4572,6 +4623,7 @@
  326. loadPHYSICSConfig();
  327. loadAccessConfig();
  328. loadModsProtection();
  329. + loadSchemeBuffConfig();
  330. loadPvpConfig();
  331. loadCraftConfig();
  332.  
  333. diff --git a/head-src/com/l2jfrozen/gameserver/GameServer.java b/head-src/com/l2jfrozen/gameserver/GameServer.java
  334. index 3e4d951..9742b98 100644
  335. --- a/head-src/com/l2jfrozen/gameserver/GameServer.java
  336. +++ b/head-src/com/l2jfrozen/gameserver/GameServer.java
  337. @@ -61,6 +61,7 @@
  338. import com.l2jfrozen.gameserver.datatables.sql.AccessLevels;
  339. import com.l2jfrozen.gameserver.datatables.sql.AdminCommandAccessRights;
  340. import com.l2jfrozen.gameserver.datatables.sql.ArmorSetsTable;
  341. +import com.l2jfrozen.gameserver.datatables.sql.BufferTable;
  342. import com.l2jfrozen.gameserver.datatables.sql.CharNameTable;
  343. import com.l2jfrozen.gameserver.datatables.sql.CharTemplateTable;
  344. import com.l2jfrozen.gameserver.datatables.sql.ClanTable;
  345. @@ -153,6 +154,8 @@
  346. import com.l2jfrozen.util.Util;
  347. import com.l2jfrozen.util.database.L2DatabaseFactory;
  348.  
  349. +import Dev.SpecialMods.XMLDocumentFactory;
  350. +
  351. public class GameServer
  352. {
  353. private static Logger LOGGER = Logger.getLogger("Loader");
  354. @@ -284,6 +287,7 @@
  355. FishTable.getInstance();
  356.  
  357. Util.printSection("Npc");
  358. + BufferTable.getInstance();
  359. NpcWalkerRoutesTable.getInstance().load();
  360. if (!NpcTable.getInstance().isInitialized())
  361. {
  362. @@ -362,6 +366,7 @@
  363. DimensionalRiftManager.getInstance();
  364.  
  365. Util.printSection("Misc");
  366. + XMLDocumentFactory.getInstance();
  367. RecipeTable.getInstance();
  368. RecipeController.getInstance();
  369. EventDroplist.getInstance();
  370. diff --git a/head-src/com/l2jfrozen/gameserver/Shutdown.java b/head-src/com/l2jfrozen/gameserver/Shutdown.java
  371. index 254380c..2c5e655 100644
  372. --- a/head-src/com/l2jfrozen/gameserver/Shutdown.java
  373. +++ b/head-src/com/l2jfrozen/gameserver/Shutdown.java
  374. @@ -26,6 +26,7 @@
  375. import com.l2jfrozen.gameserver.controllers.GameTimeController;
  376. import com.l2jfrozen.gameserver.controllers.TradeController;
  377. import com.l2jfrozen.gameserver.datatables.OfflineTradeTable;
  378. +import com.l2jfrozen.gameserver.datatables.sql.BufferTable;
  379. import com.l2jfrozen.gameserver.managers.AutoSaveManager;
  380. import com.l2jfrozen.gameserver.managers.CastleManorManager;
  381. import com.l2jfrozen.gameserver.managers.CursedWeaponsManager;
  382. @@ -699,6 +700,10 @@
  383. // Save all manor data
  384. CastleManorManager.getInstance().save();
  385.  
  386. + // Schemes save.
  387. + BufferTable.getInstance().saveSchemes();
  388. + LOGGER.info("BufferTable data has been saved.");
  389. +
  390. // Save all global (non-player specific) Quest data that needs to persist after reboot
  391. if (!Config.ALT_DEV_NO_QUESTS)
  392. QuestManager.getInstance().save();
  393. diff --git a/head-src/com/l2jfrozen/gameserver/datatables/sql/BufferTable.java b/head-src/com/l2jfrozen/gameserver/datatables/sql/BufferTable.java
  394. new file mode 100644
  395. index 0000000..6964ef1
  396. --- /dev/null
  397. +++ b/head-src/com/l2jfrozen/gameserver/datatables/sql/BufferTable.java
  398. @@ -0,0 +1,247 @@
  399. +package com.l2jfrozen.gameserver.datatables.sql;
  400. +
  401. +import java.io.File;
  402. +import java.sql.Connection;
  403. +import java.sql.PreparedStatement;
  404. +import java.sql.ResultSet;
  405. +import java.util.ArrayList;
  406. +import java.util.Collections;
  407. +import java.util.HashMap;
  408. +import java.util.LinkedHashMap;
  409. +import java.util.List;
  410. +import java.util.Map;
  411. +import java.util.concurrent.ConcurrentHashMap;
  412. +import java.util.logging.Logger;
  413. +
  414. +import org.w3c.dom.Document;
  415. +import org.w3c.dom.NamedNodeMap;
  416. +import org.w3c.dom.Node;
  417. +
  418. +import com.l2jfrozen.Config;
  419. +import com.l2jfrozen.util.StringUtil;
  420. +import com.l2jfrozen.util.database.L2DatabaseFactory;
  421. +
  422. +import Dev.SpecialMods.BuffSkillHolder;
  423. +import Dev.SpecialMods.XMLDocumentFactory;
  424. +
  425. +/**
  426. + * This class loads available skills and stores players' buff schemes into _schemesTable.
  427. + */
  428. +public class BufferTable
  429. +{
  430. + private static final Logger _log = Logger.getLogger(BufferTable.class.getName());
  431. +
  432. + private static final String LOAD_SCHEMES = "SELECT * FROM buffer_schemes";
  433. + private static final String DELETE_SCHEMES = "TRUNCATE TABLE buffer_schemes";
  434. + private static final String INSERT_SCHEME = "INSERT INTO buffer_schemes (object_id, scheme_name, skills) VALUES (?,?,?)";
  435. +
  436. + private final Map<Integer, HashMap<String, ArrayList<Integer>>> _schemesTable = new ConcurrentHashMap<>();
  437. + private final Map<Integer, BuffSkillHolder> _availableBuffs = new LinkedHashMap<>();
  438. +
  439. + public BufferTable()
  440. + {
  441. + int count = 0;
  442. +
  443. + try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  444. + {
  445. + PreparedStatement st = con.prepareStatement(LOAD_SCHEMES);
  446. + ResultSet rs = st.executeQuery();
  447. +
  448. + while (rs.next())
  449. + {
  450. + final int objectId = rs.getInt("object_id");
  451. +
  452. + final String schemeName = rs.getString("scheme_name");
  453. + final String[] skills = rs.getString("skills").split(",");
  454. +
  455. + ArrayList<Integer> schemeList = new ArrayList<>();
  456. +
  457. + for (String skill : skills)
  458. + {
  459. + // Don't feed the skills list if the list is empty.
  460. + if (skill.isEmpty())
  461. + break;
  462. +
  463. + schemeList.add(Integer.valueOf(skill));
  464. + }
  465. +
  466. + setScheme(objectId, schemeName, schemeList);
  467. + count++;
  468. + }
  469. +
  470. + rs.close();
  471. + st.close();
  472. + }
  473. + catch (Exception e)
  474. + {
  475. + _log.warning("BufferTable: Failed to load buff schemes : " + e);
  476. + }
  477. +
  478. + try
  479. + {
  480. + final File f = new File("./data/xml/buffer_skills.xml");
  481. + final Document doc = XMLDocumentFactory.getInstance().loadDocument(f);
  482. + final Node n = doc.getFirstChild();
  483. +
  484. + for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
  485. + {
  486. + if (!d.getNodeName().equalsIgnoreCase("category"))
  487. + continue;
  488. +
  489. + final String category = d.getAttributes().getNamedItem("type").getNodeValue();
  490. +
  491. + for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
  492. + {
  493. + if (!c.getNodeName().equalsIgnoreCase("buff"))
  494. + continue;
  495. +
  496. + final NamedNodeMap attrs = c.getAttributes();
  497. + final int skillId = Integer.parseInt(attrs.getNamedItem("id").getNodeValue());
  498. +
  499. + _availableBuffs.put(skillId, new BuffSkillHolder(skillId, Integer.parseInt(attrs.getNamedItem("price").getNodeValue()), category, attrs.getNamedItem("desc").getNodeValue()));
  500. + }
  501. + }
  502. + }
  503. + catch (Exception e)
  504. + {
  505. + _log.warning("BufferTable: Failed to load buff info : " + e);
  506. + }
  507. + _log.info("BufferTable: Loaded " + count + " players schemes and " + _availableBuffs.size() + " available buffs.");
  508. + }
  509. +
  510. + public void saveSchemes()
  511. + {
  512. + try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  513. + {
  514. + // Delete all entries from database.
  515. + PreparedStatement st = con.prepareStatement(DELETE_SCHEMES);
  516. + st.execute();
  517. + st.close();
  518. +
  519. + st = con.prepareStatement(INSERT_SCHEME);
  520. +
  521. + // Save _schemesTable content.
  522. + for (Map.Entry<Integer, HashMap<String, ArrayList<Integer>>> player : _schemesTable.entrySet())
  523. + {
  524. + for (Map.Entry<String, ArrayList<Integer>> scheme : player.getValue().entrySet())
  525. + {
  526. + // Build a String composed of skill ids seperated by a ",".
  527. + final StringBuilder sb = new StringBuilder();
  528. + for (int skillId : scheme.getValue())
  529. + StringUtil.append(sb, skillId, ",");
  530. +
  531. + // Delete the last "," : must be called only if there is something to delete !
  532. + if (sb.length() > 0)
  533. + sb.setLength(sb.length() - 1);
  534. +
  535. + st.setInt(1, player.getKey());
  536. + st.setString(2, scheme.getKey());
  537. + st.setString(3, sb.toString());
  538. + st.addBatch();
  539. + }
  540. + }
  541. + st.executeBatch();
  542. + st.close();
  543. + }
  544. + catch (Exception e)
  545. + {
  546. + _log.warning("BufferTable: Error while saving schemes : " + e);
  547. + }
  548. + }
  549. +
  550. + public void setScheme(int playerId, String schemeName, ArrayList<Integer> list)
  551. + {
  552. + if (!_schemesTable.containsKey(playerId))
  553. + _schemesTable.put(playerId, new HashMap<String, ArrayList<Integer>>());
  554. + else if (_schemesTable.get(playerId).size() >= Config.BUFFER_MAX_SCHEMES)
  555. + return;
  556. +
  557. + _schemesTable.get(playerId).put(schemeName, list);
  558. + }
  559. +
  560. + /**
  561. + * @param playerId : The player objectId to check.
  562. + * @return the list of schemes for a given player.
  563. + */
  564. + public Map<String, ArrayList<Integer>> getPlayerSchemes(int playerId)
  565. + {
  566. + return _schemesTable.get(playerId);
  567. + }
  568. +
  569. + /**
  570. + * @param playerId : The player objectId to check.
  571. + * @param schemeName : The scheme name to check.
  572. + * @return the List holding skills for the given scheme name and player, or null (if scheme or player isn't registered).
  573. + */
  574. + public List<Integer> getScheme(int playerId, String schemeName)
  575. + {
  576. + if (_schemesTable.get(playerId) == null || _schemesTable.get(playerId).get(schemeName) == null)
  577. + return Collections.emptyList();
  578. +
  579. + return _schemesTable.get(playerId).get(schemeName);
  580. + }
  581. +
  582. + /**
  583. + * @param playerId : The player objectId to check.
  584. + * @param schemeName : The scheme name to check.
  585. + * @param skillId : The skill id to check.
  586. + * @return true if the skill is already registered on the scheme, or false otherwise.
  587. + */
  588. + public boolean getSchemeContainsSkill(int playerId, String schemeName, int skillId)
  589. + {
  590. + final List<Integer> skills = getScheme(playerId, schemeName);
  591. + if (skills.isEmpty())
  592. + return false;
  593. +
  594. + for (int id : skills)
  595. + {
  596. + if (id == skillId)
  597. + return true;
  598. + }
  599. + return false;
  600. + }
  601. +
  602. + /**
  603. + * @param groupType : The type of skills to return.
  604. + * @return a list of skills ids based on the given groupType.
  605. + */
  606. + public List<Integer> getSkillsIdsByType(String groupType)
  607. + {
  608. + List<Integer> skills = new ArrayList<>();
  609. + for (BuffSkillHolder skill : _availableBuffs.values())
  610. + {
  611. + if (skill.getType().equalsIgnoreCase(groupType))
  612. + skills.add(skill.getId());
  613. + }
  614. + return skills;
  615. + }
  616. +
  617. + /**
  618. + * @return a list of all buff types available.
  619. + */
  620. + public List<String> getSkillTypes()
  621. + {
  622. + List<String> skillTypes = new ArrayList<>();
  623. + for (BuffSkillHolder skill : _availableBuffs.values())
  624. + {
  625. + if (!skillTypes.contains(skill.getType()))
  626. + skillTypes.add(skill.getType());
  627. + }
  628. + return skillTypes;
  629. + }
  630. +
  631. + public BuffSkillHolder getAvailableBuff(int skillId)
  632. + {
  633. + return _availableBuffs.get(skillId);
  634. + }
  635. +
  636. + public static BufferTable getInstance()
  637. + {
  638. + return SingletonHolder.INSTANCE;
  639. + }
  640. +
  641. + private static class SingletonHolder
  642. + {
  643. + protected static final BufferTable INSTANCE = new BufferTable();
  644. + }
  645. +}
  646. \ No newline at end of file
  647. diff --git a/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2BufferInstance.java b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2BufferInstance.java
  648. new file mode 100644
  649. index 0000000..907d075
  650. --- /dev/null
  651. +++ b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2BufferInstance.java
  652. @@ -0,0 +1,560 @@
  653. +/*
  654. + * This program is free software; you can redistribute it and/or modify
  655. + * it under the terms of the GNU General Public License as published by
  656. + * the Free Software Foundation; either version 2, or (at your option)
  657. + * any later version.
  658. + *
  659. + * This program is distributed in the hope that it will be useful,
  660. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  661. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  662. + * GNU General Public License for more details.
  663. + *
  664. + * You should have received a copy of the GNU General Public License
  665. + * along with this program; if not, write to the Free Software
  666. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  667. + * 02111-1307, USA.
  668. + *
  669. + * http://www.gnu.org/copyleft/gpl.html
  670. + */
  671. +package com.l2jfrozen.gameserver.model.actor.instance;
  672. +
  673. +import java.util.ArrayList;
  674. +import java.util.List;
  675. +import java.util.Map;
  676. +import java.util.StringTokenizer;
  677. +
  678. +import com.l2jfrozen.Config;
  679. +import com.l2jfrozen.gameserver.ai.CtrlIntention;
  680. +import com.l2jfrozen.gameserver.datatables.SkillTable;
  681. +import com.l2jfrozen.gameserver.datatables.sql.BufferTable;
  682. +import com.l2jfrozen.gameserver.model.L2Character;
  683. +import com.l2jfrozen.gameserver.model.L2Skill;
  684. +import com.l2jfrozen.gameserver.model.L2Summon;
  685. +import com.l2jfrozen.gameserver.network.SystemMessageId;
  686. +import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
  687. +import com.l2jfrozen.gameserver.network.serverpackets.MagicSkillUser;
  688. +import com.l2jfrozen.gameserver.network.serverpackets.MyTargetSelected;
  689. +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
  690. +import com.l2jfrozen.gameserver.network.serverpackets.SocialAction;
  691. +import com.l2jfrozen.gameserver.network.serverpackets.SystemMessage;
  692. +import com.l2jfrozen.gameserver.network.serverpackets.ValidateLocation;
  693. +import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
  694. +import com.l2jfrozen.util.StringUtil;
  695. +import com.l2jfrozen.util.random.Rnd;
  696. +
  697. +import Dev.SpecialMods.MathUtil;
  698. +
  699. +public class L2BufferInstance extends L2NpcInstance
  700. +{
  701. + private static final int PAGE_LIMIT = 6;
  702. +
  703. + public L2BufferInstance(int objectId, L2NpcTemplate template)
  704. + {
  705. + super(objectId, template);
  706. + }
  707. +
  708. + @Override
  709. + public void onAction(L2PcInstance player)
  710. + {
  711. + if (this != player.getTarget())
  712. + {
  713. + player.setTarget(this);
  714. + player.sendPacket(new MyTargetSelected(getObjectId(), player.getLevel() - getLevel()));
  715. + player.sendPacket(new ValidateLocation(this));
  716. + }
  717. + else if (isInsideRadius(player, INTERACTION_DISTANCE, false, false))
  718. + {
  719. +
  720. + SocialAction sa = new SocialAction(getObjectId(), Rnd.get(8));
  721. + broadcastPacket(sa);
  722. + showSubBufferWindow(player);
  723. + player.sendPacket(ActionFailed.STATIC_PACKET);
  724. + }
  725. + else
  726. + {
  727. + player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
  728. + player.sendPacket(ActionFailed.STATIC_PACKET);
  729. + }
  730. + }
  731. +
  732. + @Override
  733. + public void onBypassFeedback(L2PcInstance player, String command)
  734. + {
  735. + StringTokenizer st = new StringTokenizer(command, " ");
  736. + String currentCommand = st.nextToken();
  737. +
  738. + if (currentCommand.startsWith("menu"))
  739. + {
  740. + NpcHtmlMessage html = new NpcHtmlMessage(1);
  741. + html.setFile(getHtmlPath(getNpcId(), 0));
  742. + html.replace("%objectId%", getObjectId());
  743. + player.sendPacket(html);
  744. + }
  745. + else if (currentCommand.equalsIgnoreCase("getbuff"))
  746. + {
  747. + int buffid = 0;
  748. + int bufflevel = 1;
  749. + String nextWindow = null;
  750. +
  751. + if (st.countTokens() == 3)
  752. + {
  753. + buffid = Integer.valueOf(st.nextToken());
  754. + bufflevel = Integer.valueOf(st.nextToken());
  755. + nextWindow = st.nextToken();
  756. + }
  757. + else if (st.countTokens() == 1)
  758. + buffid = Integer.valueOf(st.nextToken());
  759. +
  760. + if (buffid != 0)
  761. + {
  762. + player.broadcastPacket(new MagicSkillUser(this, player, buffid, bufflevel, 5, 0));
  763. +
  764. + player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT).addSkillName(buffid, bufflevel));
  765. + SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, player);
  766. + showSubBufferWindow(player);
  767. + showChatWindow(player, nextWindow);
  768. + }
  769. + }
  770. + else if (currentCommand.equalsIgnoreCase("vipbuff"))
  771. + {
  772. + int buffid = 0;
  773. + int bufflevel = 1;
  774. + String nextWindow = null;
  775. +
  776. + if (st.countTokens() == 3)
  777. + {
  778. + buffid = Integer.valueOf(st.nextToken());
  779. + bufflevel = Integer.valueOf(st.nextToken());
  780. + nextWindow = st.nextToken();
  781. + }
  782. + else if (st.countTokens() == 1)
  783. + buffid = Integer.valueOf(st.nextToken());
  784. +
  785. + if (!player.isGM())
  786. + {
  787. + player.sendMessage("You must be vip to get this buff.");
  788. + showChatWindow(player, nextWindow);
  789. + return;
  790. + }
  791. +
  792. + if (buffid != 0)
  793. + {
  794. + player.broadcastPacket(new MagicSkillUser(this, player, buffid, bufflevel, 5, 0));
  795. +
  796. + player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT).addSkillName(buffid, bufflevel));
  797. + SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, player);
  798. + showSubBufferWindow(player);
  799. + showChatWindow(player, nextWindow);
  800. + }
  801. + }
  802. + else if (currentCommand.equalsIgnoreCase("paybuff"))
  803. + {
  804. + int buffid = 0;
  805. + int bufflevel = 1;
  806. + int buffPrice = 0;
  807. + String nextWindow = null;
  808. +
  809. + if (st.countTokens() == 4)
  810. + {
  811. + buffid = Integer.valueOf(st.nextToken());
  812. + bufflevel = Integer.valueOf(st.nextToken());
  813. + buffPrice = Integer.valueOf(st.nextToken());
  814. + nextWindow = st.nextToken();
  815. + }
  816. + else if (st.countTokens() == 3)
  817. + {
  818. + buffid = Integer.valueOf(st.nextToken());
  819. + bufflevel = Integer.valueOf(st.nextToken());
  820. + nextWindow = st.nextToken();
  821. + }
  822. + else if (st.countTokens() == 1)
  823. + buffid = Integer.valueOf(st.nextToken());
  824. +
  825. + if (buffid != 0 && player.destroyItemByItemId("buff",Config.COIN_ITEMID ,buffPrice, player.getLastFolkNPC(), true))
  826. + {
  827. + player.broadcastPacket(new MagicSkillUser(this, player, buffid, bufflevel, 5, 0));
  828. + player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT).addSkillName(buffid, bufflevel));
  829. + SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, player);
  830. + showChatWindow(player, nextWindow);
  831. + }
  832. + else
  833. + showSubBufferWindow(player);
  834. + }
  835. + else if (currentCommand.equalsIgnoreCase("fbuff"))
  836. + {
  837. + player.stopAllEffects();
  838. +
  839. + for (Integer skillid : Config.FIGHTER_BUFF_LIST)
  840. + {
  841. + L2Skill skill = SkillTable.getInstance().getInfo(skillid, SkillTable.getInstance().getMaxLevel(skillid, 0));
  842. + if (skill != null)
  843. + skill.getEffects(player, player);
  844. + }
  845. +
  846. + player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
  847. + player.setCurrentCp(player.getMaxCp());
  848. + player.sendMessage("You get a Fighter-buff complect.");
  849. +
  850. + showSubBufferWindow(player);
  851. + }
  852. + else if (currentCommand.equalsIgnoreCase("mbuff"))
  853. + {
  854. + player.stopAllEffects();
  855. +
  856. +
  857. + for (Integer skillid : Config.MAGE_BUFF_LIST)
  858. + {
  859. + L2Skill skill = SkillTable.getInstance().getInfo(skillid, SkillTable.getInstance().getMaxLevel(skillid, 0));
  860. + if (skill != null)
  861. + skill.getEffects(player, player);
  862. + }
  863. +
  864. + player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
  865. + player.setCurrentCp(player.getMaxCp());
  866. + player.sendMessage("You get a Mage-buff complect.");
  867. +
  868. + showSubBufferWindow(player);
  869. + }
  870. + else if (currentCommand.startsWith("cleanup"))
  871. + {
  872. + player.broadcastPacket(new MagicSkillUser(this, player, 1056, 12, 100, 0));
  873. + player.stopAllEffects();
  874. +
  875. + final L2Summon summon = player.getPet();
  876. + if (summon != null)
  877. + summon.stopAllEffects();
  878. + NpcHtmlMessage html = new NpcHtmlMessage(1);
  879. + html.setFile(getHtmlPath(getNpcId(), 0));
  880. + html.replace("%objectId%", getObjectId());
  881. + player.sendPacket(html);
  882. + }
  883. + else if (currentCommand.startsWith("heal"))
  884. + {
  885. + player.broadcastPacket(new MagicSkillUser(this, player, 1218, 33, 100, 0));
  886. +
  887. + player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
  888. + player.setCurrentCp(player.getMaxCp());
  889. +
  890. + final L2Summon summon = player.getPet();
  891. + if (summon != null)
  892. + summon.setCurrentHpMp(summon.getMaxHp(), summon.getMaxMp());
  893. +
  894. + NpcHtmlMessage html = new NpcHtmlMessage(1);
  895. + html.setFile(getHtmlPath(getNpcId(), 0));
  896. + html.replace("%objectId%", getObjectId());
  897. + player.sendPacket(html);
  898. + }
  899. + else if (currentCommand.startsWith("support"))
  900. + {
  901. + try
  902. + {
  903. + showGiveBuffsWindow(player);
  904. + }
  905. + catch(Exception e)
  906. + {
  907. + e.printStackTrace();
  908. + }
  909. + }
  910. + else if (currentCommand.startsWith("givebuffs"))
  911. + {
  912. + try
  913. + {
  914. + final String schemeName = st.nextToken();
  915. + //final int cost = Integer.parseInt(st.nextToken());
  916. +
  917. + L2Character target = null;
  918. + if (st.hasMoreTokens())
  919. + {
  920. + final String targetType = st.nextToken();
  921. + if (targetType != null && targetType.equalsIgnoreCase("pet"))
  922. + target = player.getPet();
  923. + }
  924. + else
  925. + target = player;
  926. +
  927. + if (target == null)
  928. + player.sendMessage("You don't have a pet.");
  929. +
  930. + else
  931. + //else if (cost == 0 || player.reduceAdena("NPC Buffer", cost, this, true))
  932. + //{
  933. + for (int skillId : BufferTable.getInstance().getScheme(player.getObjectId(), schemeName))
  934. + SkillTable.getInstance().getInfo(skillId, SkillTable.getInstance().getMaxLevel(skillId, 0)).getEffects(this, target);
  935. + //}
  936. + }
  937. + catch (Exception e)
  938. + {
  939. + e.printStackTrace();
  940. + }
  941. + }
  942. + else if (currentCommand.startsWith("editschemes"))
  943. + {
  944. + showEditSchemeWindow(player, st.nextToken(), st.nextToken(), Integer.parseInt(st.nextToken()));
  945. + }
  946. + else if (currentCommand.startsWith("skill"))
  947. + {
  948. + final String groupType = st.nextToken();
  949. + final String schemeName = st.nextToken();
  950. +
  951. + final int skillId = Integer.parseInt(st.nextToken());
  952. + final int page = Integer.parseInt(st.nextToken());
  953. +
  954. + final List<Integer> skills = BufferTable.getInstance().getScheme(player.getObjectId(), schemeName);
  955. +
  956. + if (currentCommand.startsWith("skillselect") && !schemeName.equalsIgnoreCase("none"))
  957. + {
  958. + if (skills.size() < player.getMaxBuffCount())
  959. + skills.add(skillId);
  960. + else
  961. + player.sendMessage("This scheme has reached the maximum amount of buffs.");
  962. + }
  963. + else if (currentCommand.startsWith("skillunselect"))
  964. + skills.remove(Integer.valueOf(skillId));
  965. +
  966. + showEditSchemeWindow(player, groupType, schemeName, page);
  967. + }
  968. + else if (currentCommand.startsWith("subbuffer"))
  969. + {
  970. + showSubBufferWindow(player);
  971. + }
  972. + else if (currentCommand.startsWith("createscheme"))
  973. + {
  974. + try
  975. + {
  976. + final String schemeName = st.nextToken();
  977. + if (schemeName.length() > 14)
  978. + {
  979. + player.sendMessage("Scheme's name must contain up to 14 chars. Spaces are trimmed.");
  980. + return;
  981. + }
  982. +
  983. + final Map<String, ArrayList<Integer>> schemes = BufferTable.getInstance().getPlayerSchemes(player.getObjectId());
  984. + if (schemes != null)
  985. + {
  986. + if (schemes.size() == Config.BUFFER_MAX_SCHEMES)
  987. + {
  988. + player.sendMessage("Maximum schemes amount is already reached.");
  989. + return;
  990. + }
  991. +
  992. + if (schemes.containsKey(schemeName))
  993. + {
  994. + player.sendMessage("The scheme name already exists.");
  995. + return;
  996. + }
  997. + }
  998. +
  999. + BufferTable.getInstance().setScheme(player.getObjectId(), schemeName.trim(), new ArrayList<Integer>());
  1000. + showGiveBuffsWindow(player);
  1001. + }
  1002. + catch (Exception e)
  1003. + {
  1004. + player.sendMessage("Scheme's name must contain up to 14 chars. Spaces are trimmed.");
  1005. + }
  1006. + }
  1007. + else if (currentCommand.startsWith("deletescheme"))
  1008. + {
  1009. + try
  1010. + {
  1011. + final String schemeName = st.nextToken();
  1012. + final Map<String, ArrayList<Integer>> schemes = BufferTable.getInstance().getPlayerSchemes(player.getObjectId());
  1013. +
  1014. + if (schemes != null && schemes.containsKey(schemeName))
  1015. + schemes.remove(schemeName);
  1016. + }
  1017. + catch (Exception e)
  1018. + {
  1019. + player.sendMessage("This scheme name is invalid.");
  1020. + }
  1021. + showGiveBuffsWindow(player);
  1022. + }
  1023. + else
  1024. + super.onBypassFeedback(player, command);
  1025. + }
  1026. +
  1027. + @Override
  1028. + public String getHtmlPath(int npcId, int val)
  1029. + {
  1030. + String filename = "";
  1031. + if (val == 0)
  1032. + filename = "" + npcId;
  1033. + else
  1034. + filename = npcId + "-" + val;
  1035. +
  1036. + return "data/html/mods/buffer/" + filename + ".htm";
  1037. + }
  1038. +
  1039. + private void showSubBufferWindow(L2PcInstance player)
  1040. + {
  1041. + NpcHtmlMessage html = new NpcHtmlMessage(1);
  1042. +
  1043. + html.setFile(getHtmlPath(getNpcId(), 0));
  1044. + html.replace("%objectId%", getObjectId());
  1045. + player.sendPacket(html);
  1046. + }
  1047. +
  1048. + /**
  1049. + * Sends an html packet to player with Give Buffs menu info for player and pet, depending on targetType parameter {player, pet}
  1050. + * @param player : The player to make checks on.
  1051. + */
  1052. + private void showGiveBuffsWindow(L2PcInstance player)
  1053. + {
  1054. + final StringBuilder sb = new StringBuilder(200);
  1055. +
  1056. + final Map<String, ArrayList<Integer>> schemes = BufferTable.getInstance().getPlayerSchemes(player.getObjectId());
  1057. + if (schemes == null || schemes.isEmpty())
  1058. + sb.append("<font color=\"LEVEL\">You haven't defined any scheme.</font>");
  1059. + else
  1060. + {
  1061. + for (Map.Entry<String, ArrayList<Integer>> scheme : schemes.entrySet())
  1062. + {
  1063. + StringUtil.append(sb, "<font color=\"LEVEL\">", scheme.getKey(), " [", scheme.getValue().size(), " / ", player.getMaxBuffCount(), "]</font><br1>");
  1064. + StringUtil.append(sb, "<a action=\"bypass -h npc_%objectId%_givebuffs ", scheme.getKey(), "\">Use on Me</a>&nbsp;|&nbsp;");
  1065. + StringUtil.append(sb, "<a action=\"bypass -h npc_%objectId%_givebuffs ", scheme.getKey(), " pet\">Use on Pet</a>&nbsp;|&nbsp;");
  1066. + StringUtil.append(sb, "<a action=\"bypass -h npc_%objectId%_editschemes Buffs ", scheme.getKey(), " 1\">Edit</a>&nbsp;|&nbsp;");
  1067. + StringUtil.append(sb, "<a action=\"bypass -h npc_%objectId%_deletescheme ", scheme.getKey(), "\">Delete</a><br>");
  1068. + }
  1069. + }
  1070. +
  1071. + final NpcHtmlMessage html = new NpcHtmlMessage(0);
  1072. + html.setFile(getHtmlPath(getNpcId(), 1));
  1073. + html.replace("%schemes%", sb.toString());
  1074. + html.replace("%max_schemes%", Config.BUFFER_MAX_SCHEMES);
  1075. + html.replace("%objectId%", getObjectId());
  1076. + player.sendPacket(html);
  1077. + }
  1078. +
  1079. + /**
  1080. + * This sends an html packet to player with Edit Scheme Menu info. This allows player to edit each created scheme (add/delete skills)
  1081. + * @param player : The player to make checks on.
  1082. + * @param groupType : The group of skills to select.
  1083. + * @param schemeName : The scheme to make check.
  1084. + * @param page The page.
  1085. + */
  1086. + private void showEditSchemeWindow(L2PcInstance player, String groupType, String schemeName, int page)
  1087. + {
  1088. + final NpcHtmlMessage html = new NpcHtmlMessage(0);
  1089. + final List<Integer> schemeSkills = BufferTable.getInstance().getScheme(player.getObjectId(), schemeName);
  1090. +
  1091. + html.setFile(getHtmlPath(getNpcId(), 2));
  1092. + html.replace("%schemename%", schemeName);
  1093. + html.replace("%count%", schemeSkills.size() + " / " + player.getMaxBuffCount());
  1094. + html.replace("%typesframe%", getTypesFrame(groupType, schemeName));
  1095. + html.replace("%skilllistframe%", getGroupSkillList(player, groupType, schemeName, page));
  1096. + html.replace("%objectId%", getObjectId());
  1097. + player.sendPacket(html);
  1098. + }
  1099. +
  1100. + /**
  1101. + * @param player : The player to make checks on.
  1102. + * @param groupType : The group of skills to select.
  1103. + * @param schemeName : The scheme to make check.
  1104. + * @param page The page.
  1105. + * @return a String representing skills available to selection for a given groupType.
  1106. + */
  1107. + private String getGroupSkillList(L2PcInstance player, String groupType, String schemeName, int page)
  1108. + {
  1109. + // Retrieve the entire skills list based on group type.
  1110. + List<Integer> skills = BufferTable.getInstance().getSkillsIdsByType(groupType);
  1111. + if (skills.isEmpty())
  1112. + return "That group doesn't contain any skills.";
  1113. +
  1114. + // Calculate page number.
  1115. + final int max = MathUtil.countPagesNumber(skills.size(), PAGE_LIMIT);
  1116. + if (page > max)
  1117. + page = max;
  1118. +
  1119. + // Cut skills list up to page number.
  1120. + skills = skills.subList((page - 1) * PAGE_LIMIT, Math.min(page * PAGE_LIMIT, skills.size()));
  1121. +
  1122. + final List<Integer> schemeSkills = BufferTable.getInstance().getScheme(player.getObjectId(), schemeName);
  1123. + final StringBuilder sb = new StringBuilder(skills.size() * 150);
  1124. +
  1125. + int row = 0;
  1126. + for (int skillId : skills)
  1127. + {
  1128. + sb.append(((row % 2) == 0 ? "<table width=\"280\" bgcolor=\"000000\"><tr>" : "<table width=\"280\"><tr>"));
  1129. +
  1130. + if (skillId < 100)
  1131. + {
  1132. + if (schemeSkills.contains(skillId))
  1133. + StringUtil.append(sb, "<td height=40 width=40><img src=\"icon.skill00", skillId, "\" width=32 height=32></td><td width=190>", SkillTable.getInstance().getInfo(skillId, 1).getName(), "<br1><font color=\"B09878\">", BufferTable.getInstance().getAvailableBuff(skillId).getDescription(), "</font></td><td><button action=\"bypass -h npc_%objectId%_skillunselect ", groupType, " ", schemeName, " ", skillId, " ", page, "\" width=32 height=32 back=\"L2UI_CH3.mapbutton_zoomout2\" fore=\"L2UI_CH3.mapbutton_zoomout1\"></td>");
  1134. + else
  1135. + StringUtil.append(sb, "<td height=40 width=40><img src=\"icon.skill00", skillId, "\" width=32 height=32></td><td width=190>", SkillTable.getInstance().getInfo(skillId, 1).getName(), "<br1><font color=\"B09878\">", BufferTable.getInstance().getAvailableBuff(skillId).getDescription(), "</font></td><td><button action=\"bypass -h npc_%objectId%_skillselect ", groupType, " ", schemeName, " ", skillId, " ", page, "\" width=32 height=32 back=\"L2UI_CH3.mapbutton_zoomin2\" fore=\"L2UI_CH3.mapbutton_zoomin1\"></td>");
  1136. + }
  1137. + else if (skillId < 1000)
  1138. + {
  1139. + if (schemeSkills.contains(skillId))
  1140. + StringUtil.append(sb, "<td height=40 width=40><img src=\"icon.skill0", skillId, "\" width=32 height=32></td><td width=190>", SkillTable.getInstance().getInfo(skillId, 1).getName(), "<br1><font color=\"B09878\">", BufferTable.getInstance().getAvailableBuff(skillId).getDescription(), "</font></td><td><button action=\"bypass -h npc_%objectId%_skillunselect ", groupType, " ", schemeName, " ", skillId, " ", page, "\" width=32 height=32 back=\"L2UI_CH3.mapbutton_zoomout2\" fore=\"L2UI_CH3.mapbutton_zoomout1\"></td>");
  1141. + else
  1142. + StringUtil.append(sb, "<td height=40 width=40><img src=\"icon.skill0", skillId, "\" width=32 height=32></td><td width=190>", SkillTable.getInstance().getInfo(skillId, 1).getName(), "<br1><font color=\"B09878\">", BufferTable.getInstance().getAvailableBuff(skillId).getDescription(), "</font></td><td><button action=\"bypass -h npc_%objectId%_skillselect ", groupType, " ", schemeName, " ", skillId, " ", page, "\" width=32 height=32 back=\"L2UI_CH3.mapbutton_zoomin2\" fore=\"L2UI_CH3.mapbutton_zoomin1\"></td>");
  1143. + }
  1144. + else
  1145. + {
  1146. + if (schemeSkills.contains(skillId))
  1147. + StringUtil.append(sb, "<td height=40 width=40><img src=\"icon.skill", skillId, "\" width=32 height=32></td><td width=190>", SkillTable.getInstance().getInfo(skillId, 1).getName(), "<br1><font color=\"B09878\">", BufferTable.getInstance().getAvailableBuff(skillId).getDescription(), "</font></td><td><button action=\"bypass -h npc_%objectId%_skillunselect ", groupType, " ", schemeName, " ", skillId, " ", page, "\" width=32 height=32 back=\"L2UI_CH3.mapbutton_zoomout2\" fore=\"L2UI_CH3.mapbutton_zoomout1\"></td>");
  1148. + else
  1149. + StringUtil.append(sb, "<td height=40 width=40><img src=\"icon.skill", skillId, "\" width=32 height=32></td><td width=190>", SkillTable.getInstance().getInfo(skillId, 1).getName(), "<br1><font color=\"B09878\">", BufferTable.getInstance().getAvailableBuff(skillId).getDescription(), "</font></td><td><button action=\"bypass -h npc_%objectId%_skillselect ", groupType, " ", schemeName, " ", skillId, " ", page, "\" width=32 height=32 back=\"L2UI_CH3.mapbutton_zoomin2\" fore=\"L2UI_CH3.mapbutton_zoomin1\"></td>");
  1150. + }
  1151. +
  1152. + sb.append("</tr></table><img src=\"L2UI.SquareGray\" width=277 height=1>");
  1153. + row++;
  1154. + }
  1155. +
  1156. + // Build page footer.
  1157. + sb.append("<br><img src=\"L2UI.SquareGray\" width=277 height=1><table width=\"100%\" bgcolor=000000><tr>");
  1158. +
  1159. + if (page > 1)
  1160. + StringUtil.append(sb, "<td align=left width=70><a action=\"bypass -h npc_" + getObjectId() + "_editschemes ", groupType, " ", schemeName, " ", page - 1, "\">Previous</a></td>");
  1161. + else
  1162. + StringUtil.append(sb, "<td align=left width=70>Previous</td>");
  1163. +
  1164. + StringUtil.append(sb, "<td align=center width=100>Page ", page, "</td>");
  1165. +
  1166. + if (page < max)
  1167. + StringUtil.append(sb, "<td align=right width=70><a action=\"bypass -h npc_" + getObjectId() + "_editschemes ", groupType, " ", schemeName, " ", page + 1, "\">Next</a></td>");
  1168. + else
  1169. + StringUtil.append(sb, "<td align=right width=70>Next</td>");
  1170. +
  1171. + sb.append("</tr></table><img src=\"L2UI.SquareGray\" width=277 height=1>");
  1172. +
  1173. + return sb.toString();
  1174. + }
  1175. +
  1176. + /**
  1177. + * @param groupType : The group of skills to select.
  1178. + * @param schemeName : The scheme to make check.
  1179. + * @return a string representing all groupTypes available. The group currently on selection isn't linkable.
  1180. + */
  1181. + private static String getTypesFrame(String groupType, String schemeName)
  1182. + {
  1183. + final StringBuilder sb = new StringBuilder(500);
  1184. + sb.append("<table>");
  1185. +
  1186. + int count = 0;
  1187. + for (String type : BufferTable.getInstance().getSkillTypes())
  1188. + {
  1189. + if (count == 0)
  1190. + sb.append("<tr>");
  1191. +
  1192. + if (groupType.equalsIgnoreCase(type))
  1193. + StringUtil.append(sb, "<td width=65>", type, "</td>");
  1194. + else
  1195. + StringUtil.append(sb, "<td width=65><a action=\"bypass -h npc_%objectId%_editschemes ", type, " ", schemeName, " 1\">", type, "</a></td>");
  1196. +
  1197. + count++;
  1198. + if (count == 4)
  1199. + {
  1200. + sb.append("</tr>");
  1201. + count = 0;
  1202. + }
  1203. + }
  1204. +
  1205. + if (!sb.toString().endsWith("</tr>"))
  1206. + sb.append("</tr>");
  1207. +
  1208. + sb.append("</table>");
  1209. +
  1210. + return sb.toString();
  1211. + }
  1212. +}
  1213. \ No newline at end of file
  1214. diff --git a/head-src/com/l2jfrozen/util/StringUtil.java b/head-src/com/l2jfrozen/util/StringUtil.java
  1215. index da2aa35..41288de 100644
  1216. --- a/head-src/com/l2jfrozen/util/StringUtil.java
  1217. +++ b/head-src/com/l2jfrozen/util/StringUtil.java
  1218. @@ -262,4 +262,15 @@
  1219. TextBuilder.recycle(sbString);
  1220. return result;
  1221. }
  1222. +
  1223. + /**
  1224. + * Appends objects to an existing StringBuilder.
  1225. + * @param sb : the StringBuilder to edit.
  1226. + * @param content : parameters to append.
  1227. + */
  1228. + public static void append(StringBuilder sb, Object... content)
  1229. + {
  1230. + for (Object obj : content)
  1231. + sb.append((obj == null) ? null : obj.toString());
  1232. + }
  1233. }
  1234.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement