Advertisement
Sarada-L2

Scheme Buff Acis 394+

Mar 3rd, 2021
1,648
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.27 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/config/npcs.properties b/config/npcs.properties
  26. index c05f8a9..5e7c237 100644
  27. --- a/config/npcs.properties
  28. +++ b/config/npcs.properties
  29. @@ -1,14 +1,4 @@
  30. #=============================================================
  31. -# Buffer
  32. -#=============================================================
  33. -
  34. -# Maximum number of available schemes per player.
  35. -BufferMaxSchemesPerChar = 4
  36. -
  37. -# Static cost of buffs ; override skills price if different of -1.
  38. -BufferStaticCostPerBuff = -1
  39. -
  40. -#=============================================================
  41. # Class Master
  42. #=============================================================
  43.  
  44. diff --git a/java/net/sf/l2j/Config.java b/java/net/sf/l2j/Config.java
  45. index d95e5bb..d780bd3 100644
  46. --- a/java/net/sf/l2j/Config.java
  47. +++ b/java/net/sf/l2j/Config.java
  48. @@ -36,12 +36,18 @@
  49. public static final String PLAYERS_FILE = "./config/players.properties";
  50. public static final String SERVER_FILE = "./config/server.properties";
  51. public static final String SIEGE_FILE = "./config/siege.properties";
  52. -
  53. + public static final String SCHEMEBUFF = "./config/CustomMods/SchemeBuff.ini";
  54. // --------------------------------------------------
  55. // Clans settings
  56. // --------------------------------------------------
  57.  
  58. /** Clans */
  59. + /** Buffer */
  60. + public static int COIN_ITEMID;
  61. + public static String FIGHTER_BUFF;
  62. + public static ArrayList<Integer> FIGHTER_BUFF_LIST = new ArrayList<>();
  63. + public static String MAGE_BUFF;
  64. + public static ArrayList<Integer> MAGE_BUFF_LIST = new ArrayList<>();
  65. public static int CLAN_JOIN_DAYS;
  66. public static int CLAN_CREATE_DAYS;
  67. public static int CLAN_DISSOLVE_DAYS;
  68. @@ -901,9 +907,6 @@
  69. {
  70. final ExProperties npcs = initProperties(NPCS_FILE);
  71.  
  72. - BUFFER_MAX_SCHEMES = npcs.getProperty("BufferMaxSchemesPerChar", 4);
  73. - BUFFER_STATIC_BUFF_COST = npcs.getProperty("BufferStaticCostPerBuff", -1);
  74. -
  75. ALLOW_CLASS_MASTERS = npcs.getProperty("AllowClassMasters", false);
  76. ALLOW_ENTIRE_TREE = npcs.getProperty("AllowEntireTree", false);
  77. if (ALLOW_CLASS_MASTERS)
  78. @@ -1093,7 +1096,26 @@
  79. MAX_BUFFS_AMOUNT = players.getProperty("MaxBuffsAmount", 20);
  80. STORE_SKILL_COOLTIME = players.getProperty("StoreSkillCooltime", true);
  81. }
  82. -
  83. + private static final void loadScheme()
  84. + {
  85. + final ExProperties buff = initProperties(SCHEMEBUFF);
  86. + BUFFER_MAX_SCHEMES = buff.getProperty("BufferMaxSchemesPerChar", 4);
  87. + BUFFER_STATIC_BUFF_COST = buff.getProperty("BufferStaticCostPerBuff", -1);
  88. + COIN_ITEMID = Integer.parseInt(buff.getProperty("CoinIdPriceBuff", "-1"));
  89. + FIGHTER_BUFF = buff.getProperty("FighterBuffList", "0");
  90. + FIGHTER_BUFF_LIST = new ArrayList<>();
  91. + for (String id : FIGHTER_BUFF.trim().split(","))
  92. + {
  93. + FIGHTER_BUFF_LIST.add(Integer.parseInt(id.trim()));
  94. + }
  95. +
  96. + MAGE_BUFF = buff.getProperty("MageBuffList", "0");
  97. + MAGE_BUFF_LIST = new ArrayList<>();
  98. + for (String id : MAGE_BUFF.trim().split(","))
  99. + {
  100. + MAGE_BUFF_LIST.add(Integer.parseInt(id.trim()));
  101. + }
  102. + }
  103. /**
  104. * Loads siege settings.
  105. */
  106. @@ -1307,7 +1329,7 @@
  107.  
  108. // siege settings
  109. loadSieges();
  110. -
  111. + loadScheme();
  112. // server settings
  113. loadServer();
  114. }
  115. diff --git a/java/net/sf/l2j/gameserver/model/actor/instance/SchemeBuffer.java b/java/net/sf/l2j/gameserver/model/actor/instance/SchemeBuffer.java
  116. new file mode 100644
  117. index 0000000..11dedce
  118. --- /dev/null
  119. +++ b/java/net/sf/l2j/gameserver/model/actor/instance/SchemeBuffer.java
  120. @@ -0,0 +1,528 @@
  121. +/*
  122. + * This program is free software; you can redistribute it and/or modify
  123. + * it under the terms of the GNU General Public License as published by
  124. + * the Free Software Foundation; either version 2, or (at your option)
  125. + * any later version.
  126. + *
  127. + * This program is distributed in the hope that it will be useful,
  128. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  129. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  130. + * GNU General Public License for more details.
  131. + *
  132. + * You should have received a copy of the GNU General Public License
  133. + * along with this program; if not, write to the Free Software
  134. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  135. + * 02111-1307, USA.
  136. + *
  137. + * http://www.gnu.org/copyleft/gpl.html
  138. + */
  139. +package net.sf.l2j.gameserver.model.actor.instance;
  140. +
  141. +import java.util.ArrayList;
  142. +import java.util.List;
  143. +import java.util.Map;
  144. +import java.util.StringTokenizer;
  145. +
  146. +import net.sf.l2j.Config;
  147. +
  148. +import net.sf.l2j.commons.lang.StringUtil;
  149. +import net.sf.l2j.commons.math.MathUtil;
  150. +import net.sf.l2j.gameserver.data.SkillTable;
  151. +import net.sf.l2j.gameserver.data.manager.BufferManager;
  152. +import net.sf.l2j.gameserver.model.actor.Creature;
  153. +import net.sf.l2j.gameserver.model.actor.Player;
  154. +import net.sf.l2j.gameserver.model.actor.Summon;
  155. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  156. +import net.sf.l2j.gameserver.network.SystemMessageId;
  157. +import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
  158. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  159. +import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  160. +import net.sf.l2j.gameserver.skills.L2Skill;
  161. +
  162. +public class SchemeBuffer extends Folk
  163. +{
  164. + private static final int PAGE_LIMIT = 6;
  165. +
  166. + public SchemeBuffer(int objectId, NpcTemplate template)
  167. + {
  168. + super(objectId, template);
  169. + }
  170. +
  171. + @Override
  172. + public void onBypassFeedback(Player player, String command)
  173. + {
  174. + StringTokenizer st = new StringTokenizer(command, " ");
  175. + String currentCommand = st.nextToken();
  176. +
  177. + if (currentCommand.startsWith("menu"))
  178. + {
  179. + NpcHtmlMessage html = new NpcHtmlMessage(1);
  180. + html.setFile(getHtmlPath(getNpcId(), 0));
  181. + html.replace("%objectId%", getObjectId());
  182. + player.sendPacket(html);
  183. + }
  184. + else if (currentCommand.equalsIgnoreCase("getbuff"))
  185. + {
  186. + int buffid = 0;
  187. + int bufflevel = 1;
  188. + String nextWindow = null;
  189. +
  190. + if (st.countTokens() == 3)
  191. + {
  192. + buffid = Integer.valueOf(st.nextToken());
  193. + bufflevel = Integer.valueOf(st.nextToken());
  194. + nextWindow = st.nextToken();
  195. + }
  196. + else if (st.countTokens() == 1)
  197. + buffid = Integer.valueOf(st.nextToken());
  198. +
  199. + if (buffid != 0)
  200. + {
  201. + player.broadcastPacket(new MagicSkillUse(this, player, buffid, bufflevel, 5, 0));
  202. +
  203. + player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT).addSkillName(buffid, bufflevel));
  204. + SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, player);
  205. + showSubBufferWindow(player);
  206. + showChatWindow(player, nextWindow);
  207. + }
  208. + }
  209. + else if (currentCommand.equalsIgnoreCase("vipbuff"))
  210. + {
  211. + int buffid = 0;
  212. + int bufflevel = 1;
  213. + String nextWindow = null;
  214. +
  215. + if (st.countTokens() == 3)
  216. + {
  217. + buffid = Integer.valueOf(st.nextToken());
  218. + bufflevel = Integer.valueOf(st.nextToken());
  219. + nextWindow = st.nextToken();
  220. + }
  221. + else if (st.countTokens() == 1)
  222. + buffid = Integer.valueOf(st.nextToken());
  223. +
  224. + if (!player.isGM())
  225. + {
  226. + player.sendMessage("You must be vip to get this buff.");
  227. + showChatWindow(player, nextWindow);
  228. + return;
  229. + }
  230. +
  231. + if (buffid != 0)
  232. + {
  233. + player.broadcastPacket(new MagicSkillUse(this, player, buffid, bufflevel, 5, 0));
  234. +
  235. + player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT).addSkillName(buffid, bufflevel));
  236. + SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, player);
  237. + showSubBufferWindow(player);
  238. + showChatWindow(player, nextWindow);
  239. + }
  240. + }
  241. + else if (currentCommand.equalsIgnoreCase("paybuff"))
  242. + {
  243. + int buffid = 0;
  244. + int bufflevel = 1;
  245. + int buffPrice = 0;
  246. + String nextWindow = null;
  247. +
  248. + if (st.countTokens() == 4)
  249. + {
  250. + buffid = Integer.valueOf(st.nextToken());
  251. + bufflevel = Integer.valueOf(st.nextToken());
  252. + buffPrice = Integer.valueOf(st.nextToken());
  253. + nextWindow = st.nextToken();
  254. + }
  255. + else if (st.countTokens() == 3)
  256. + {
  257. + buffid = Integer.valueOf(st.nextToken());
  258. + bufflevel = Integer.valueOf(st.nextToken());
  259. + nextWindow = st.nextToken();
  260. + }
  261. + else if (st.countTokens() == 1)
  262. + buffid = Integer.valueOf(st.nextToken());
  263. +
  264. + if (buffid != 0 && player.destroyItemByItemId("buff",Config.COIN_ITEMID ,buffPrice, player.getCurrentFolk(), true))
  265. + {
  266. + player.broadcastPacket(new MagicSkillUse(this, player, buffid, bufflevel, 5, 0));
  267. + player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT).addSkillName(buffid, bufflevel));
  268. + SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, player);
  269. + showChatWindow(player, nextWindow);
  270. + }
  271. + else
  272. + showSubBufferWindow(player);
  273. + }
  274. + else if (currentCommand.equalsIgnoreCase("fbuff"))
  275. + {
  276. + player.stopAllEffectsExceptThoseThatLastThroughDeath();
  277. +
  278. + for (Integer skillid : Config.FIGHTER_BUFF_LIST)
  279. + {
  280. + L2Skill skill = SkillTable.getInstance().getInfo(skillid, SkillTable.getInstance().getMaxLevel(skillid));
  281. + if (skill != null)
  282. + skill.getEffects(player, player);
  283. + }
  284. +
  285. + player.getStatus().setMaxCpHpMp();
  286. + player.sendMessage("You get a Fighter-buff complect.");
  287. +
  288. + showSubBufferWindow(player);
  289. + }
  290. + else if (currentCommand.equalsIgnoreCase("mbuff"))
  291. + {
  292. + player.stopAllEffectsExceptThoseThatLastThroughDeath();
  293. +
  294. + for (Integer skillid : Config.MAGE_BUFF_LIST)
  295. + {
  296. + L2Skill skill = SkillTable.getInstance().getInfo(skillid, SkillTable.getInstance().getMaxLevel(skillid));
  297. + if (skill != null)
  298. + skill.getEffects(player, player);
  299. + }
  300. +
  301. + player.getStatus().setMaxCpHpMp();
  302. + player.sendMessage("You get a Mage-buff complect.");
  303. +
  304. + showSubBufferWindow(player);
  305. + }
  306. + else if (currentCommand.startsWith("cleanup"))
  307. + {
  308. + player.broadcastPacket(new MagicSkillUse(this, player, 1056, 12, 100, 0));
  309. + player.stopAllEffectsExceptThoseThatLastThroughDeath();
  310. +
  311. + final Summon summon = player.getSummon();
  312. + if (summon != null)
  313. + summon.stopAllEffectsExceptThoseThatLastThroughDeath();
  314. +
  315. + NpcHtmlMessage html = new NpcHtmlMessage(1);
  316. + html.setFile(getHtmlPath(getNpcId(), 0));
  317. + html.replace("%objectId%", getObjectId());
  318. + player.sendPacket(html);
  319. + }
  320. + else if (currentCommand.startsWith("heal"))
  321. + {
  322. + player.broadcastPacket(new MagicSkillUse(this, player, 1218, 33, 100, 0));
  323. +
  324. + player.getStatus().setMaxCpHpMp();
  325. +
  326. + final Summon summon = player.getSummon();
  327. + if (summon != null)
  328. + summon.getStatus().setMaxHpMp();
  329. +
  330. + NpcHtmlMessage html = new NpcHtmlMessage(1);
  331. + html.setFile(getHtmlPath(getNpcId(), 0));
  332. + html.replace("%objectId%", getObjectId());
  333. + player.sendPacket(html);
  334. + }
  335. + else if (currentCommand.startsWith("support"))
  336. + {
  337. + try
  338. + {
  339. + showGiveBuffsWindow(player);
  340. + }
  341. + catch(Exception e)
  342. + {
  343. + e.printStackTrace();
  344. + }
  345. + }
  346. + else if (currentCommand.startsWith("givebuffs"))
  347. + {
  348. + try
  349. + {
  350. + final String schemeName = st.nextToken();
  351. + //final int cost = Integer.parseInt(st.nextToken());
  352. +
  353. + Creature target = null;
  354. + if (st.hasMoreTokens())
  355. + {
  356. + final String targetType = st.nextToken();
  357. + if (targetType != null && targetType.equalsIgnoreCase("pet"))
  358. + target = player.getSummon();
  359. + }
  360. + else
  361. + target = player;
  362. +
  363. + if (target == null)
  364. + player.sendMessage("You don't have a pet.");
  365. +
  366. + else
  367. + //else if (cost == 0 || player.reduceAdena("NPC Buffer", cost, this, true))
  368. + //{
  369. + for (int skillId : BufferManager.getInstance().getScheme(player.getObjectId(), schemeName))
  370. + SkillTable.getInstance().getInfo(skillId, SkillTable.getInstance().getMaxLevel(skillId)).getEffects(this, target);
  371. + //}
  372. + }
  373. + catch (Exception e)
  374. + {
  375. + e.printStackTrace();
  376. + }
  377. + }
  378. + else if (currentCommand.startsWith("editschemes"))
  379. + {
  380. + showEditSchemeWindow(player, st.nextToken(), st.nextToken(), Integer.parseInt(st.nextToken()));
  381. + }
  382. + else if (currentCommand.startsWith("skill"))
  383. + {
  384. + final String groupType = st.nextToken();
  385. + final String schemeName = st.nextToken();
  386. +
  387. + final int skillId = Integer.parseInt(st.nextToken());
  388. + final int page = Integer.parseInt(st.nextToken());
  389. +
  390. + final List<Integer> skills = BufferManager.getInstance().getScheme(player.getObjectId(), schemeName);
  391. +
  392. + if (currentCommand.startsWith("skillselect") && !schemeName.equalsIgnoreCase("none"))
  393. + {
  394. + if (skills.size() < player.getMaxBuffCount())
  395. + skills.add(skillId);
  396. + else
  397. + player.sendMessage("This scheme has reached the maximum amount of buffs.");
  398. + }
  399. + else if (currentCommand.startsWith("skillunselect"))
  400. + skills.remove(Integer.valueOf(skillId));
  401. +
  402. + showEditSchemeWindow(player, groupType, schemeName, page);
  403. + }
  404. + else if (currentCommand.startsWith("subbuffer"))
  405. + {
  406. + showSubBufferWindow(player);
  407. + }
  408. + else if (currentCommand.startsWith("createscheme"))
  409. + {
  410. + try
  411. + {
  412. + final String schemeName = st.nextToken();
  413. + if (schemeName.length() > 14)
  414. + {
  415. + player.sendMessage("Scheme's name must contain up to 14 chars. Spaces are trimmed.");
  416. + return;
  417. + }
  418. +
  419. + final Map<String, ArrayList<Integer>> schemes = BufferManager.getInstance().getPlayerSchemes(player.getObjectId());
  420. + if (schemes != null)
  421. + {
  422. + if (schemes.size() == Config.BUFFER_MAX_SCHEMES)
  423. + {
  424. + player.sendMessage("Maximum schemes amount is already reached.");
  425. + return;
  426. + }
  427. +
  428. + if (schemes.containsKey(schemeName))
  429. + {
  430. + player.sendMessage("The scheme name already exists.");
  431. + return;
  432. + }
  433. + }
  434. +
  435. + BufferManager.getInstance().setScheme(player.getObjectId(), schemeName.trim(), new ArrayList<Integer>());
  436. + showGiveBuffsWindow(player);
  437. + }
  438. + catch (Exception e)
  439. + {
  440. + player.sendMessage("Scheme's name must contain up to 14 chars. Spaces are trimmed.");
  441. + }
  442. + }
  443. + else if (currentCommand.startsWith("deletescheme"))
  444. + {
  445. + try
  446. + {
  447. + final String schemeName = st.nextToken();
  448. + final Map<String, ArrayList<Integer>> schemes = BufferManager.getInstance().getPlayerSchemes(player.getObjectId());
  449. +
  450. + if (schemes != null && schemes.containsKey(schemeName))
  451. + schemes.remove(schemeName);
  452. + }
  453. + catch (Exception e)
  454. + {
  455. + player.sendMessage("This scheme name is invalid.");
  456. + }
  457. + showGiveBuffsWindow(player);
  458. + }
  459. + else
  460. + super.onBypassFeedback(player, command);
  461. + }
  462. +
  463. + @Override
  464. + public String getHtmlPath(int npcId, int val)
  465. + {
  466. + String filename = "";
  467. + if (val == 0)
  468. + filename = "" + npcId;
  469. + else
  470. + filename = npcId + "-" + val;
  471. +
  472. + return "data/html/mods/buffer/" + filename + ".htm";
  473. + }
  474. +
  475. + private void showSubBufferWindow(Player player)
  476. + {
  477. + NpcHtmlMessage html = new NpcHtmlMessage(1);
  478. +
  479. + html.setFile(getHtmlPath(getNpcId(), 0));
  480. + html.replace("%objectId%", getObjectId());
  481. + player.sendPacket(html);
  482. + }
  483. +
  484. + /**
  485. + * Sends an html packet to player with Give Buffs menu info for player and pet, depending on targetType parameter {player, pet}
  486. + * @param player : The player to make checks on.
  487. + */
  488. + private void showGiveBuffsWindow(Player player)
  489. + {
  490. + final StringBuilder sb = new StringBuilder(200);
  491. +
  492. + final Map<String, ArrayList<Integer>> schemes = BufferManager.getInstance().getPlayerSchemes(player.getObjectId());
  493. + if (schemes == null || schemes.isEmpty())
  494. + sb.append("<font color=\"LEVEL\">You haven't defined any scheme.</font>");
  495. + else
  496. + {
  497. + for (Map.Entry<String, ArrayList<Integer>> scheme : schemes.entrySet())
  498. + {
  499. + StringUtil.append(sb, "<font color=\"LEVEL\">", scheme.getKey(), " [", scheme.getValue().size(), " / ", player.getMaxBuffCount(), "]</font><br1>");
  500. + StringUtil.append(sb, "<a action=\"bypass npc_%objectId%_givebuffs ", scheme.getKey(), "\">Use on Me</a>&nbsp;|&nbsp;");
  501. + StringUtil.append(sb, "<a action=\"bypass npc_%objectId%_givebuffs ", scheme.getKey(), " pet\">Use on Pet</a>&nbsp;|&nbsp;");
  502. + StringUtil.append(sb, "<a action=\"bypass npc_%objectId%_editschemes Buffs ", scheme.getKey(), " 1\">Edit</a>&nbsp;|&nbsp;");
  503. + StringUtil.append(sb, "<a action=\"bypass npc_%objectId%_deletescheme ", scheme.getKey(), "\">Delete</a><br>");
  504. + }
  505. + }
  506. +
  507. + final NpcHtmlMessage html = new NpcHtmlMessage(0);
  508. + html.setFile(getHtmlPath(getNpcId(), 1));
  509. + html.replace("%schemes%", sb.toString());
  510. + html.replace("%max_schemes%", Config.BUFFER_MAX_SCHEMES);
  511. + html.replace("%objectId%", getObjectId());
  512. + player.sendPacket(html);
  513. + }
  514. +
  515. + /**
  516. + * This sends an html packet to player with Edit Scheme Menu info. This allows player to edit each created scheme (add/delete skills)
  517. + * @param player : The player to make checks on.
  518. + * @param groupType : The group of skills to select.
  519. + * @param schemeName : The scheme to make check.
  520. + * @param page The page.
  521. + */
  522. + private void showEditSchemeWindow(Player player, String groupType, String schemeName, int page)
  523. + {
  524. + final NpcHtmlMessage html = new NpcHtmlMessage(0);
  525. + final List<Integer> schemeSkills = BufferManager.getInstance().getScheme(player.getObjectId(), schemeName);
  526. +
  527. + html.setFile(getHtmlPath(getNpcId(), 2));
  528. + html.replace("%schemename%", schemeName);
  529. + html.replace("%count%", schemeSkills.size() + " / " + player.getMaxBuffCount());
  530. + html.replace("%typesframe%", getTypesFrame(groupType, schemeName));
  531. + html.replace("%skilllistframe%", getGroupSkillList(player, groupType, schemeName, page));
  532. + html.replace("%objectId%", getObjectId());
  533. + player.sendPacket(html);
  534. + }
  535. +
  536. + /**
  537. + * @param player : The player to make checks on.
  538. + * @param groupType : The group of skills to select.
  539. + * @param schemeName : The scheme to make check.
  540. + * @param page The page.
  541. + * @return a String representing skills available to selection for a given groupType.
  542. + */
  543. + private String getGroupSkillList(Player player, String groupType, String schemeName, int page)
  544. + {
  545. + // Retrieve the entire skills list based on group type.
  546. + List<Integer> skills = BufferManager.getInstance().getSkillsIdsByType(groupType);
  547. + if (skills.isEmpty())
  548. + return "That group doesn't contain any skills.";
  549. +
  550. + // Calculate page number.
  551. + final int max = MathUtil.countPagesNumber(skills.size(), PAGE_LIMIT);
  552. + if (page > max)
  553. + page = max;
  554. +
  555. + // Cut skills list up to page number.
  556. + skills = skills.subList((page - 1) * PAGE_LIMIT, Math.min(page * PAGE_LIMIT, skills.size()));
  557. +
  558. + final List<Integer> schemeSkills = BufferManager.getInstance().getScheme(player.getObjectId(), schemeName);
  559. + final StringBuilder sb = new StringBuilder(skills.size() * 150);
  560. +
  561. + int row = 0;
  562. + for (int skillId : skills)
  563. + {
  564. + sb.append(((row % 2) == 0 ? "<table width=\"280\" bgcolor=\"000000\"><tr>" : "<table width=\"280\"><tr>"));
  565. +
  566. + if (skillId < 100)
  567. + {
  568. + if (schemeSkills.contains(skillId))
  569. + 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\">", BufferManager.getInstance().getAvailableBuff(skillId).getDescription(), "</font></td><td><button action=\"bypass npc_%objectId%_skillunselect ", groupType, " ", schemeName, " ", skillId, " ", page, "\" width=32 height=32 back=\"L2UI_CH3.mapbutton_zoomout2\" fore=\"L2UI_CH3.mapbutton_zoomout1\"></td>");
  570. + else
  571. + 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\">", BufferManager.getInstance().getAvailableBuff(skillId).getDescription(), "</font></td><td><button action=\"bypass npc_%objectId%_skillselect ", groupType, " ", schemeName, " ", skillId, " ", page, "\" width=32 height=32 back=\"L2UI_CH3.mapbutton_zoomin2\" fore=\"L2UI_CH3.mapbutton_zoomin1\"></td>");
  572. + }
  573. + else if (skillId < 1000)
  574. + {
  575. + if (schemeSkills.contains(skillId))
  576. + 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\">", BufferManager.getInstance().getAvailableBuff(skillId).getDescription(), "</font></td><td><button action=\"bypass npc_%objectId%_skillunselect ", groupType, " ", schemeName, " ", skillId, " ", page, "\" width=32 height=32 back=\"L2UI_CH3.mapbutton_zoomout2\" fore=\"L2UI_CH3.mapbutton_zoomout1\"></td>");
  577. + else
  578. + 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\">", BufferManager.getInstance().getAvailableBuff(skillId).getDescription(), "</font></td><td><button action=\"bypass npc_%objectId%_skillselect ", groupType, " ", schemeName, " ", skillId, " ", page, "\" width=32 height=32 back=\"L2UI_CH3.mapbutton_zoomin2\" fore=\"L2UI_CH3.mapbutton_zoomin1\"></td>");
  579. + }
  580. + else
  581. + {
  582. + if (schemeSkills.contains(skillId))
  583. + 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\">", BufferManager.getInstance().getAvailableBuff(skillId).getDescription(), "</font></td><td><button action=\"bypass npc_%objectId%_skillunselect ", groupType, " ", schemeName, " ", skillId, " ", page, "\" width=32 height=32 back=\"L2UI_CH3.mapbutton_zoomout2\" fore=\"L2UI_CH3.mapbutton_zoomout1\"></td>");
  584. + else
  585. + 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\">", BufferManager.getInstance().getAvailableBuff(skillId).getDescription(), "</font></td><td><button action=\"bypass npc_%objectId%_skillselect ", groupType, " ", schemeName, " ", skillId, " ", page, "\" width=32 height=32 back=\"L2UI_CH3.mapbutton_zoomin2\" fore=\"L2UI_CH3.mapbutton_zoomin1\"></td>");
  586. + }
  587. +
  588. + sb.append("</tr></table><img src=\"L2UI.SquareGray\" width=277 height=1>");
  589. + row++;
  590. + }
  591. +
  592. + // Build page footer.
  593. + sb.append("<br><img src=\"L2UI.SquareGray\" width=277 height=1><table width=\"100%\" bgcolor=000000><tr>");
  594. +
  595. + if (page > 1)
  596. + StringUtil.append(sb, "<td align=left width=70><a action=\"bypass npc_" + getObjectId() + "_editschemes ", groupType, " ", schemeName, " ", page - 1, "\">Previous</a></td>");
  597. + else
  598. + StringUtil.append(sb, "<td align=left width=70>Previous</td>");
  599. +
  600. + StringUtil.append(sb, "<td align=center width=100>Page ", page, "</td>");
  601. +
  602. + if (page < max)
  603. + StringUtil.append(sb, "<td align=right width=70><a action=\"bypass npc_" + getObjectId() + "_editschemes ", groupType, " ", schemeName, " ", page + 1, "\">Next</a></td>");
  604. + else
  605. + StringUtil.append(sb, "<td align=right width=70>Next</td>");
  606. +
  607. + sb.append("</tr></table><img src=\"L2UI.SquareGray\" width=277 height=1>");
  608. +
  609. + return sb.toString();
  610. + }
  611. +
  612. + /**
  613. + * @param groupType : The group of skills to select.
  614. + * @param schemeName : The scheme to make check.
  615. + * @return a string representing all groupTypes available. The group currently on selection isn't linkable.
  616. + */
  617. + private static String getTypesFrame(String groupType, String schemeName)
  618. + {
  619. + final StringBuilder sb = new StringBuilder(500);
  620. + sb.append("<table>");
  621. +
  622. + int count = 0;
  623. + for (String type : BufferManager.getInstance().getSkillTypes())
  624. + {
  625. + if (count == 0)
  626. + sb.append("<tr>");
  627. +
  628. + if (groupType.equalsIgnoreCase(type))
  629. + StringUtil.append(sb, "<td width=65>", type, "</td>");
  630. + else
  631. + StringUtil.append(sb, "<td width=65><a action=\"bypass npc_%objectId%_editschemes ", type, " ", schemeName, " 1\">", type, "</a></td>");
  632. +
  633. + count++;
  634. + if (count == 4)
  635. + {
  636. + sb.append("</tr>");
  637. + count = 0;
  638. + }
  639. + }
  640. +
  641. + if (!sb.toString().endsWith("</tr>"))
  642. + sb.append("</tr>");
  643. +
  644. + sb.append("</table>");
  645. +
  646. + return sb.toString();
  647. + }
  648. +}
  649. \ No newline at end of file
  650.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement