Advertisement
Guest User

L2PlayerBuffer Acis

a guest
Sep 27th, 2020
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 30.82 KB | None | 0 0
  1. Index: aCis_gameserver/java/net/sf/l2j/Config.java
  2. IDEA additional info:
  3. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  4. <+>UTF-8
  5. ===================================================================
  6. --- aCis_gameserver/java/net/sf/l2j/Config.java (revision 452cd109c3bce48416f74bba4daa8c3cf5dfc0a0)
  7. +++ aCis_gameserver/java/net/sf/l2j/Config.java (date 1601198183518)
  8. @@ -16,6 +16,7 @@
  9.  import net.sf.l2j.commons.logging.CLogger;
  10.  import net.sf.l2j.commons.math.MathUtil;
  11.  
  12. +import net.sf.l2j.gameserver.model.holder.BuffSkillHolder;
  13.  import net.sf.l2j.gameserver.model.holder.IntIntHolder;
  14.  
  15.  /**
  16. @@ -447,6 +448,26 @@
  17.     public static boolean DIVINE_SP_BOOK_NEEDED;
  18.     public static boolean SUBCLASS_WITHOUT_QUESTS;
  19.    
  20. +   /** Buffer */
  21. +   public static String PFIGHTER_SET;
  22. +   public static int[] PFIGHTER_SET_LIST;
  23. +   public static String PMAGE_SET;
  24. +   public static int[] PMAGE_SET_LIST;
  25. +   public static int PBUFFER_MAX_SCHEMES;
  26. +   public static int PBUFFER_MAX_SKILLS;
  27. +   public static int PBUFFER_STATIC_BUFF_COST;
  28. +   public static String PBUFFER_BUFFS;
  29. +   public static Map<Integer, BuffSkillHolder> PBUFFER_BUFFLIST;
  30. +
  31. +   public static List<Integer> PFIGHTER_SKILL_LIST;
  32. +   public static List<Integer> PMAGE_SKILL_LIST;
  33. +
  34. +   public static boolean PRESTRICT_USE_BUFFER_ON_PVPFLAG;
  35. +   public static boolean PRESTRICT_USE_BUFFER_IN_COMBAT;
  36. +
  37. +   public static int PVOTE_BUFF_ITEM_ID;
  38. +   public static int PVOTE_BUFF_ITEM_COUNT;
  39. +
  40.     /** Buffs */
  41.     public static boolean STORE_SKILL_COOLTIME;
  42.     public static int MAX_BUFFS_AMOUNT;
  43. @@ -1086,6 +1107,46 @@
  44.        
  45.         MAX_BUFFS_AMOUNT = players.getProperty("MaxBuffsAmount", 20);
  46.         STORE_SKILL_COOLTIME = players.getProperty("StoreSkillCooltime", true);
  47. +
  48. +       PBUFFER_MAX_SCHEMES = players.getProperty("BufferMaxSchemesPerChar", 4);
  49. +       PBUFFER_MAX_SKILLS = players.getProperty("BufferMaxSkillsPerScheme", 24);
  50. +       PBUFFER_STATIC_BUFF_COST = players.getProperty("BufferStaticCostPerBuff", -1);
  51. +       PBUFFER_BUFFS = players.getProperty("BufferBuffs");
  52. +
  53. +       PFIGHTER_SET = players.getProperty("FighterSet", "2375,3500,3501,3502,4422,4423,4424,4425,6648,6649,6650");
  54. +       PMAGE_SET = players.getProperty("MageSet", "2375,3500,3501,3502,4422,4423,4424,4425,6648,6649,6650");
  55. +
  56. +       String[] FighterList = PFIGHTER_SET.split(",");
  57. +       PFIGHTER_SET_LIST = new int[FighterList.length];
  58. +       for (int i = 0; i < FighterList.length; i++)
  59. +           PFIGHTER_SET_LIST[i] = Integer.parseInt(FighterList[i]);
  60. +
  61. +       String[] MageList = PMAGE_SET.split(",");
  62. +       PMAGE_SET_LIST = new int[MageList.length];
  63. +       for (int i = 0; i < MageList.length; i++)
  64. +           PMAGE_SET_LIST[i] = Integer.parseInt(MageList[i]);
  65. +
  66. +       PBUFFER_BUFFLIST = new HashMap<>();
  67. +       for (String skillInfo : PBUFFER_BUFFS.split(";"))
  68. +       {
  69. +           final String[] infos = skillInfo.split(",");
  70. +           PBUFFER_BUFFLIST.put(Integer.valueOf(infos[0]), new BuffSkillHolder(Integer.valueOf(infos[0]), Integer.valueOf(infos[1]), infos[2], skillInfo));
  71. +       }
  72. +
  73. +       PRESTRICT_USE_BUFFER_ON_PVPFLAG = players.getProperty("RestrictUseBufferOnPvPFlag", true);
  74. +       PRESTRICT_USE_BUFFER_IN_COMBAT = players.getProperty("RestrictUseBufferInCombat", true);
  75. +
  76. +       PVOTE_BUFF_ITEM_ID = players.getProperty("VoteBuffItemId", 57);
  77. +       PVOTE_BUFF_ITEM_COUNT = players.getProperty("VoteBuffItemCount", 1);
  78. +
  79. +       PFIGHTER_SKILL_LIST = new ArrayList<>();
  80. +       for (String skill_id : players.getProperty("FighterSkillList", "").split(";"))
  81. +           PFIGHTER_SKILL_LIST.add(Integer.parseInt(skill_id));
  82. +
  83. +       PMAGE_SKILL_LIST = new ArrayList<>();
  84. +       for (String skill_id : players.getProperty("MageSkillList", "").split(";"))
  85. +           PMAGE_SKILL_LIST.add(Integer.parseInt(skill_id));
  86. +
  87.     }
  88.    
  89.     /**
  90. Index: aCis_gameserver/config/players.properties
  91. IDEA additional info:
  92. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  93. <+>windows-1252
  94. ===================================================================
  95. --- aCis_gameserver/config/players.properties   (revision 452cd109c3bce48416f74bba4daa8c3cf5dfc0a0)
  96. +++ aCis_gameserver/config/players.properties   (date 1601197737260)
  97. @@ -252,6 +252,33 @@
  98.  # Allow player subclass addition without checking for unique quest items. Default : False.
  99.  SubClassWithoutQuests = False
  100.  
  101. +#=============================================================
  102. +#                          Buffer
  103. +#=============================================================
  104. +
  105. +# Maximum number of available schemes per player.
  106. +BufferMaxSchemesPerChar = 4
  107. +
  108. +# Maximum number of buffs per scheme.
  109. +BufferMaxSkillsPerScheme = 24
  110. +
  111. +# Static cost of buffs ; override skills price if different of -1.
  112. +BufferStaticCostPerBuff = -1
  113. +
  114. +# Fighter Set List
  115. +FighterSkillList = 1204;1045;1068;1040;1035;1086;1242;1268;1036;1240;1077;1087;271;272;274;275;310;264;266;267;268;269;270;304;305;349;364;1388;1363;4699;1393;1392;1352;1353;1354;306;1259;1182;1189;1191
  116. +# Mage Set List
  117. +MageSkillList = 1204;1048;1045;1040;1035;1085;1303;1243;1304;1036;1087;1059;1078;1062;273;365;1393;1392;1352;1353;1354;307;309;306;308;1259;1182;1191;1033;1391;1363;264;266;267;268;270;304;349;4703;276
  118. +
  119. +# Buffer List, skillId,buffPrice,type.
  120. +BufferBuffs = 264,0,Songs;265,0,Songs;266,0,Songs;267,0,Songs;268,0,Songs;269,0,Songs;270,0,Songs;304,0,Songs;305,0,Songs;306,0,Songs;308,0,Songs;349,0,Songs;363,0,Songs;364,0,Songs;271,0,Dances;272,0,Dances;273,0,Dances;274,0,Dances;275,0,Dances;276,0,Dances;277,0,Dances;309,0,Dances;310,0,Dances;311,0,Dances;307,0,Dances;365,0,Dances;1002,0,Warcryer;1006,0,Warcryer;1007,0,Warcryer;1009,0,Warcryer;1308,0,Warcryer;1309,0,Warcryer;1310,0,Warcryer;1362,0,Warcryer;1390,0,Warcryer;1391,0,Warcryer;1413,0,Warcryer;1416,0,Overlord;1003,0,Overlord;1004,0,Overlord;1005,0,Overlord;1008,0,Overlord;1249,0,Overlord;1364,0,Overlord;1365,0,Overlord;1032,0,Prophet;1033,0,Prophet;1035,0,Prophet;1036,0,Prophet;1040,0,Prophet;1043,0,Prophet;1044,0,Prophet;1045,0,Prophet;1048,0,Prophet;1059,0,Shillen_Elder;1062,0,Prophet;1068,0,Prophet;1073,0,Elder;1077,0,Shillen_Elder;1078,0,Shillen_Elder;1085,0,Prophet;1086,0,Prophet;1087,0,Elder;1182,0,Elder;1189,0,Shillen_Elder;1191,0,Prophet;1204,0,Prophet;1242,0,Shillen_Elder;1243,0,Prophet;1259,0,Elder;1268,0,Shillen_Elder;1303,0,Shillen_Elder;1304,0,Elder;1352,0,Elder;1353,0,Elder;1354,0,Elder;1388,0,Shillen_Elder;1389,0,Shillen_Elder;1392,0,Prophet;1393,0,Elder;1397,0,Elder;1355,0,Elder;4699,0,Elder;4700,0,Elder;4702,0,Elder;4703,0,Elder;1356,0,Prophet;1357,0,Shillen_Elder;1363,0,Warcryer;1414,0,Overlord
  121. +
  122. +RestrictUseBufferOnPvPFlag = true
  123. +RestrictUseBufferInCombat = true
  124. +
  125. +VoteBuffItemId = 57
  126. +VoteBuffItemCount = 15
  127. +
  128.  #=============================================================
  129.  #                        Buffs config
  130.  #=============================================================
  131. Index: aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/PlayerBuffer.java
  132. IDEA additional info:
  133. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  134. <+>UTF-8
  135. ===================================================================
  136. --- aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/PlayerBuffer.java   (date 1601198003359)
  137. +++ aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/PlayerBuffer.java   (date 1601198003359)
  138. @@ -0,0 +1,668 @@
  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.commons.lang.StringUtil;
  147. +import net.sf.l2j.commons.random.Rnd;
  148. +
  149. +import net.sf.l2j.Config;
  150. +import net.sf.l2j.gameserver.data.SkillTable;
  151. +import net.sf.l2j.gameserver.data.manager.BufferManager;
  152. +import net.sf.l2j.gameserver.enums.IntentionType;
  153. +import net.sf.l2j.gameserver.model.L2Skill;
  154. +import net.sf.l2j.gameserver.model.actor.Creature;
  155. +import net.sf.l2j.gameserver.model.actor.Npc;
  156. +import net.sf.l2j.gameserver.model.actor.Player;
  157. +import net.sf.l2j.gameserver.model.actor.Summon;
  158. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  159. +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  160. +import net.sf.l2j.gameserver.network.serverpackets.ItemList;
  161. +import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
  162. +import net.sf.l2j.gameserver.network.serverpackets.MoveToPawn;
  163. +import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected;
  164. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  165. +import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
  166. +
  167. +/**
  168. + * @author Baggos
  169. + */
  170. +public final class PlayerBuffer extends Folk
  171. +{
  172. +   public PlayerBuffer(int objectId, NpcTemplate template)
  173. +   {
  174. +       super(objectId, template);
  175. +   }
  176. +  
  177. +   @Override
  178. +   public void onAction(Player player)
  179. +   {
  180. +       if (this != player.getTarget())
  181. +       {
  182. +           player.setTarget(this);
  183. +           player.sendPacket(new MyTargetSelected(getObjectId(), 0));
  184. +           player.sendPacket(new ValidateLocation(this));
  185. +       }
  186. +       else
  187. +       {
  188. +           if (!canInteract(player))
  189. +               player.getAI().setIntention(IntentionType.INTERACT, this);
  190. +           else
  191. +           {
  192. +               // Rotate the player to face the instance
  193. +               player.sendPacket(new MoveToPawn(player, this, Npc.INTERACTION_DISTANCE));
  194. +              
  195. +               if (hasRandomAnimation())
  196. +                   onRandomAnimation(Rnd.get(8));
  197. +              
  198. +               showMainWindow(player);
  199. +              
  200. +               // Send ActionFailed to the player in order to avoid he stucks
  201. +               player.sendPacket(ActionFailed.STATIC_PACKET);
  202. +           }
  203. +       }
  204. +   }
  205. +  
  206. +   private void showMainWindow(Player activeChar)
  207. +   {      
  208. +       NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  209. +       html.setFile("data/html/mods/buffer/index.htm");
  210. +       html.replace("%objectId%", String.valueOf(getObjectId()));
  211. +       html.replace("%name%", activeChar.getName());
  212. +       html.replace("%buffcount%", "You have " + activeChar.getBuffCount() + "/" + activeChar.getMaxBuffCount() + " buffs.");
  213. +      
  214. +       activeChar.sendPacket(html);
  215. +   }
  216. +  
  217. +   @Override
  218. +   public void onBypassFeedback(Player player, String command)
  219. +   {
  220. +       if (player.getPvpFlag() > 0 && Config.PRESTRICT_USE_BUFFER_ON_PVPFLAG)
  221. +       {
  222. +           player.sendMessage("You can't use buffer when you are pvp flagged.");
  223. +           return;
  224. +       }
  225. +      
  226. +       if (player.isInCombat() && Config.PRESTRICT_USE_BUFFER_IN_COMBAT)
  227. +       {
  228. +           player.sendMessage("You can't use buffer when you are in combat.");
  229. +           return;
  230. +       }
  231. +      
  232. +       if (player.isDead())
  233. +           return;
  234. +      
  235. +       StringTokenizer st = new StringTokenizer(command, " ");
  236. +       String actualCommand = st.nextToken();
  237. +      
  238. +       if (actualCommand.equalsIgnoreCase("bufflist"))
  239. +       {
  240. +           autoBuffFunction(player, st.nextToken());
  241. +       }
  242. +       else if (actualCommand.equalsIgnoreCase("restore"))
  243. +       {
  244. +           String noble = st.nextToken();
  245. +           player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
  246. +           player.setCurrentCp(player.getMaxCp());
  247. +          
  248. +           if (noble.equals("true"))
  249. +           {
  250. +               SkillTable.getInstance().getInfo(1323, 1).getEffects(player, player);
  251. +               player.broadcastPacket(new MagicSkillUse(this, player, 1323, 1, 850, 0));
  252. +           }
  253. +          
  254. +           final Summon summon = player.getSummon();
  255. +           if (summon != null)
  256. +               summon.setCurrentHpMp(summon.getMaxHp(), summon.getMaxMp());
  257. +          
  258. +           showMainWindow(player);
  259. +       }
  260. +       else if (actualCommand.equalsIgnoreCase("cancellation"))
  261. +       {
  262. +           L2Skill buff;
  263. +           buff = SkillTable.getInstance().getInfo(1056, 1);
  264. +           buff.getEffects(this, player);
  265. +           player.stopAllEffectsExceptThoseThatLastThroughDeath();
  266. +           player.broadcastPacket(new MagicSkillUse(this, player, 1056, 1, 850, 0));
  267. +           player.stopAllEffects();
  268. +          
  269. +           final Summon summon = player.getSummon();
  270. +           if (summon != null)
  271. +               summon.stopAllEffects();
  272. +          
  273. +           showMainWindow(player);
  274. +       }
  275. +       else if (actualCommand.equalsIgnoreCase("openlist"))
  276. +       {
  277. +           String category = st.nextToken();
  278. +           String htmfile = st.nextToken();
  279. +          
  280. +           NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  281. +          
  282. +           if (category.equalsIgnoreCase("null"))
  283. +           {
  284. +               html.setFile("data/html/mods/buffer/" + htmfile + ".htm");
  285. +              
  286. +               // First Page
  287. +               if (htmfile.equals("index"))
  288. +               {
  289. +                   html.replace("%name%", player.getName());
  290. +                   html.replace("%buffcount%", "You have " + player.getBuffCount() + "/" + player.getMaxBuffCount() + " buffs.");
  291. +               }
  292. +           }
  293. +           else
  294. +               html.setFile("data/html/mods/buffer/" + category + "/" + htmfile + ".htm");
  295. +          
  296. +           html.replace("%objectId%", String.valueOf(getObjectId()));
  297. +           player.sendPacket(html);
  298. +       }
  299. +      
  300. +       else if (actualCommand.equalsIgnoreCase("dobuff"))
  301. +       {
  302. +           int buffid = Integer.valueOf(st.nextToken());
  303. +           int bufflevel = Integer.valueOf(st.nextToken());
  304. +           String category = st.nextToken();
  305. +           String windowhtml = st.nextToken();
  306. +           String votebuff = null;
  307. +          
  308. +           if (st.hasMoreTokens())
  309. +               votebuff = st.nextToken();
  310. +          
  311. +           if (windowhtml.equals("malaria"))
  312. +           {
  313. +               if (player.getInventory().getInventoryItemCount(Config.PVOTE_BUFF_ITEM_ID, 0) >= 1)
  314. +               {
  315. +                   player.getInventory().destroyItemByItemId("VoteCoins", Config.PVOTE_BUFF_ITEM_ID, 1, player, null);
  316. +                   player.getInventory().updateDatabase();
  317. +                   player.sendPacket(new ItemList(player, true));
  318. +                   player.sendMessage(1 + " Vote eye destroyed.");
  319. +               }
  320. +               else
  321. +               {
  322. +                   player.sendMessage("You dont have enough (" + 1 + ") vote item for buff.");
  323. +                   return;
  324. +               }
  325. +           }
  326. +          
  327. +           if (votebuff != null)
  328. +           {
  329. +               if (player.getInventory().getInventoryItemCount(Config.PVOTE_BUFF_ITEM_ID, 0) >= Config.PVOTE_BUFF_ITEM_COUNT)
  330. +               {
  331. +                   player.getInventory().destroyItemByItemId("VoteCoins", Config.PVOTE_BUFF_ITEM_ID, Config.PVOTE_BUFF_ITEM_COUNT, player, null);
  332. +                   player.getInventory().updateDatabase();
  333. +                   player.sendPacket(new ItemList(player, true));
  334. +                   player.sendMessage(Config.PVOTE_BUFF_ITEM_COUNT + " vote stone destroyed.");
  335. +               }
  336. +               else
  337. +               {
  338. +                   player.sendMessage("You dont have enough (" + Config.PVOTE_BUFF_ITEM_COUNT + ") vote item for buff.");
  339. +                   return;
  340. +               }
  341. +           }
  342. +          
  343. +           Creature target = player;
  344. +           if (category.equalsIgnoreCase("pet"))
  345. +           {
  346. +               if (player.getSummon() == null)
  347. +               {
  348. +                   player.sendMessage("Incorrect Pet");
  349. +                   showMainWindow(player);
  350. +                   return;
  351. +               }
  352. +               target = player.getSummon();
  353. +           }
  354. +          
  355. +           MagicSkillUse mgc = new MagicSkillUse(this, target, buffid, bufflevel, 1150, 0);
  356. +           player.sendPacket(mgc);
  357. +           player.broadcastPacket(mgc);
  358. +           SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, target);
  359. +          
  360. +           NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  361. +           html.setFile("data/html/mods/buffer/" + category + "/" + windowhtml + ".htm");
  362. +           html.replace("%objectId%", String.valueOf(getObjectId()));
  363. +           html.replace("%name%", player.getName());
  364. +           player.sendPacket(html);
  365. +       }
  366. +       else if (actualCommand.equalsIgnoreCase("getbuff"))
  367. +       {
  368. +           int buffid = Integer.valueOf(st.nextToken());
  369. +           int bufflevel = Integer.valueOf(st.nextToken());
  370. +           if (buffid != 0)
  371. +           {
  372. +               SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, player);
  373. +               broadcastPacket(new MagicSkillUse(this, player, buffid, bufflevel, 450, 0));
  374. +               showMainWindow(player);
  375. +           }
  376. +       }
  377. +       else if (actualCommand.startsWith("support"))
  378. +       {
  379. +           showGiveBuffsWindow(player, st.nextToken());
  380. +       }
  381. +       else if (actualCommand.startsWith("givebuffs"))
  382. +       {
  383. +           final String targetType = st.nextToken();
  384. +           final String schemeName = st.nextToken();
  385. +           final int cost = Integer.parseInt(st.nextToken());
  386. +          
  387. +           final Creature target = (targetType.equalsIgnoreCase("pet")) ? player.getSummon() : player;
  388. +           if (target == null)
  389. +               player.sendMessage("You don't have a pet.");
  390. +           else if (cost == 0 || player.reduceAdena("NPC Buffer", cost, this, true))
  391. +           {
  392. +               for (int skillId : BufferManager.getInstance().getScheme(player.getObjectId(), schemeName))
  393. +                   SkillTable.getInstance().getInfo(skillId, SkillTable.getInstance().getMaxLevel(skillId)).getEffects(this, target);
  394. +           }
  395. +           showGiveBuffsWindow(player, targetType);
  396. +       }
  397. +       else if (actualCommand.startsWith("editschemes"))
  398. +       {
  399. +           if (st.countTokens() == 2)
  400. +               showEditSchemeWindow(player, st.nextToken(), st.nextToken());
  401. +           else
  402. +               player.sendMessage("Something wrong with your scheme. Please contact with Admin");
  403. +       }
  404. +       else if (actualCommand.startsWith("skill"))
  405. +       {
  406. +           final String groupType = st.nextToken();
  407. +           final String schemeName = st.nextToken();
  408. +          
  409. +           final int skillId = Integer.parseInt(st.nextToken());
  410. +          
  411. +           final List<Integer> skills = BufferManager.getInstance().getScheme(player.getObjectId(), schemeName);
  412. +          
  413. +           if (actualCommand.startsWith("skillselect") && !schemeName.equalsIgnoreCase("none"))
  414. +           {
  415. +               if (skills.size() < Config.PBUFFER_MAX_SKILLS)
  416. +                   skills.add(skillId);
  417. +               else
  418. +                   player.sendMessage("This scheme has reached the maximum amount of buffs.");
  419. +           }
  420. +           else if (actualCommand.startsWith("skillunselect"))
  421. +               skills.remove(Integer.valueOf(skillId));
  422. +          
  423. +           showEditSchemeWindow(player, groupType, schemeName);
  424. +       }
  425. +       else if (actualCommand.startsWith("manageschemes"))
  426. +       {
  427. +           showManageSchemeWindow(player);
  428. +       }
  429. +       else if (actualCommand.startsWith("createscheme"))
  430. +       {
  431. +           try
  432. +           {
  433. +               final String schemeName = st.nextToken();
  434. +               if (schemeName.length() > 14)
  435. +               {
  436. +                   player.sendMessage("Scheme's name must contain up to 14 chars. Spaces are trimmed.");
  437. +                   showManageSchemeWindow(player);
  438. +                   return;
  439. +               }
  440. +              
  441. +               final Map<String, ArrayList<Integer>> schemes = BufferManager.getInstance().getPlayerSchemes(player.getObjectId());
  442. +               if (schemes != null)
  443. +               {
  444. +                   if (schemes.size() == Config.PBUFFER_MAX_SCHEMES)
  445. +                   {
  446. +                       player.sendMessage("Maximum schemes amount is already reached.");
  447. +                       showManageSchemeWindow(player);
  448. +                       return;
  449. +                   }
  450. +                  
  451. +                   if (schemes.containsKey(schemeName))
  452. +                   {
  453. +                       player.sendMessage("The scheme name already exists.");
  454. +                       showManageSchemeWindow(player);
  455. +                       return;
  456. +                   }
  457. +               }
  458. +
  459. +               BufferManager.getInstance().setScheme(player.getObjectId(), schemeName.trim(), new ArrayList<Integer>());
  460. +               showManageSchemeWindow(player);
  461. +           }
  462. +           catch (Exception e)
  463. +           {
  464. +               player.sendMessage("Scheme's name must contain up to 14 chars. Spaces are trimmed.");
  465. +               showManageSchemeWindow(player);
  466. +           }
  467. +       }
  468. +       else if (actualCommand.startsWith("deletescheme"))
  469. +       {
  470. +           try
  471. +           {
  472. +               final String schemeName = st.nextToken();
  473. +               final Map<String, ArrayList<Integer>> schemes = BufferManager.getInstance().getPlayerSchemes(player.getObjectId());
  474. +              
  475. +               if (schemes != null && schemes.containsKey(schemeName))
  476. +                   schemes.remove(schemeName);
  477. +           }
  478. +           catch (Exception e)
  479. +           {
  480. +               player.sendMessage("This scheme name is invalid.");
  481. +           }
  482. +           showManageSchemeWindow(player);
  483. +       }
  484. +       else if (actualCommand.startsWith("clearscheme"))
  485. +       {
  486. +           try
  487. +           {
  488. +               final String schemeName = st.nextToken();
  489. +               final Map<String, ArrayList<Integer>> schemes = BufferManager.getInstance().getPlayerSchemes(player.getObjectId());
  490. +              
  491. +               if (schemes != null && schemes.containsKey(schemeName))
  492. +                   schemes.get(schemeName).clear();
  493. +           }
  494. +           catch (Exception e)
  495. +           {
  496. +               player.sendMessage("This scheme name is invalid.");
  497. +           }
  498. +           showManageSchemeWindow(player);
  499. +       }
  500. +       else
  501. +           super.onBypassFeedback(player, command);
  502. +   }
  503. +  
  504. +   /**
  505. +    * Sends an html packet to player with Give Buffs menu info for player and pet, depending on targetType parameter {player, pet}
  506. +    * @param player : The player to make checks on.
  507. +    * @param targetType : a String used to define if the player or his pet must be used as target.
  508. +    */
  509. +   private void showGiveBuffsWindow(Player player, String targetType)
  510. +   {
  511. +       final StringBuilder sb = new StringBuilder(200);
  512. +      
  513. +       final Map<String, ArrayList<Integer>> schemes = BufferManager.getInstance().getPlayerSchemes(player.getObjectId());
  514. +       if (schemes == null || schemes.isEmpty())
  515. +           sb.append("<font color=\"LEVEL\">You haven't defined any scheme, please go to 'Manage my schemes' and create at least one valid scheme.</font>");
  516. +       else
  517. +       {
  518. +           for (Map.Entry<String, ArrayList<Integer>> scheme : schemes.entrySet())
  519. +           {
  520. +               final int cost = getFee(scheme.getValue());
  521. +               StringUtil.append(sb, "<font color=\"LEVEL\"><a action=\"bypass -h npc_%objectId%_givebuffs ", targetType, " ", scheme.getKey(), " ", cost, "\">", scheme.getKey(), " (", scheme.getValue().size(), " skill(s))</a>", ((cost > 0) ? " - Adena cost: " + cost : ""), "</font><br1>");
  522. +           }
  523. +       }
  524. +      
  525. +       final NpcHtmlMessage html = new NpcHtmlMessage(0);
  526. +       html.setFile("data/html/mods/buffer/schememanager/index-1.htm");
  527. +       html.replace("%schemes%", sb.toString());
  528. +       html.replace("%targettype%", (targetType.equalsIgnoreCase("pet") ? "&nbsp;<a action=\"bypass -h npc_%objectId%_support player\">yourself</a>&nbsp;|&nbsp;your pet" : "yourself&nbsp;|&nbsp;<a action=\"bypass -h npc_%objectId%_support pet\">your pet</a>"));
  529. +       html.replace("%objectId%", getObjectId());
  530. +       player.sendPacket(html);
  531. +   }
  532. +  
  533. +   /**
  534. +    * Sends an html packet to player with Manage scheme menu info. This allows player to create/delete/clear schemes
  535. +    * @param player : The player to make checks on.
  536. +    */
  537. +   private void showManageSchemeWindow(Player player)
  538. +   {
  539. +       final StringBuilder sb = new StringBuilder(200);
  540. +      
  541. +       final Map<String, ArrayList<Integer>> schemes = BufferManager.getInstance().getPlayerSchemes(player.getObjectId());
  542. +       if (schemes == null || schemes.isEmpty())
  543. +           sb.append("<font color=\"LEVEL\">You haven't created any scheme.</font>");
  544. +       else
  545. +       {
  546. +           sb.append("<table>");
  547. +           for (Map.Entry<String, ArrayList<Integer>> scheme : schemes.entrySet())
  548. +               StringUtil.append(sb, "<tr><td width=140>", scheme.getKey(), " (", scheme.getValue().size(), " skill(s))</td><td width=60><button value=\"Clear\" action=\"bypass -h npc_%objectId%_clearscheme ", scheme.getKey(), "\" width=55 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td width=60><button value=\"Drop\" action=\"bypass -h npc_%objectId%_deletescheme ", scheme.getKey(), "\" width=55 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
  549. +          
  550. +           sb.append("</table>");
  551. +       }
  552. +      
  553. +       final NpcHtmlMessage html = new NpcHtmlMessage(0);
  554. +       html.setFile("data/html/mods/buffer/schememanager/index-2.htm");
  555. +       html.replace("%schemes%", sb.toString());
  556. +       html.replace("%max_schemes%", Config.PBUFFER_MAX_SCHEMES);
  557. +       html.replace("%objectId%", getObjectId());
  558. +       player.sendPacket(html);
  559. +   }
  560. +  
  561. +   /**
  562. +    * This sends an html packet to player with Edit Scheme Menu info. This allows player to edit each created scheme (add/delete skills)
  563. +    * @param player : The player to make checks on.
  564. +    * @param groupType : The group of skills to select.
  565. +    * @param schemeName : The scheme to make check.
  566. +    */
  567. +   private void showEditSchemeWindow(Player player, String groupType, String schemeName)
  568. +   {
  569. +       final NpcHtmlMessage html = new NpcHtmlMessage(0);
  570. +      
  571. +       if (schemeName.equalsIgnoreCase("none"))
  572. +           html.setFile("data/html/mods/buffer/schememanager/index-3.htm");
  573. +       else
  574. +       {
  575. +           if (groupType.equalsIgnoreCase("none"))
  576. +               html.setFile("data/html/mods/buffer/schememanager/index-4.htm");
  577. +           else
  578. +           {
  579. +               html.setFile("data/html/mods/buffer/schememanager/index-5.htm");
  580. +               html.replace("%skilllistframe%", getGroupSkillList(player, groupType, schemeName));
  581. +           }
  582. +           html.replace("%schemename%", schemeName);
  583. +           html.replace("%myschemeframe%", getPlayerSchemeSkillList(player, groupType, schemeName));
  584. +           html.replace("%typesframe%", getTypesFrame(groupType, schemeName));
  585. +       }
  586. +       html.replace("%schemes%", getPlayerSchemes(player, schemeName));
  587. +       html.replace("%objectId%", getObjectId());
  588. +       player.sendPacket(html);
  589. +   }
  590. +  
  591. +   /**
  592. +    * @param player : The player to make checks on.
  593. +    * @param schemeName : The name to don't link (previously clicked).
  594. +    * @return a String listing player's schemes. The scheme currently on selection isn't linkable.
  595. +    */
  596. +   private static String getPlayerSchemes(Player player, String schemeName)
  597. +   {
  598. +       final Map<String, ArrayList<Integer>> schemes = BufferManager.getInstance().getPlayerSchemes(player.getObjectId());
  599. +       if (schemes == null || schemes.isEmpty())
  600. +           return "Please create at least one scheme.";
  601. +      
  602. +       final StringBuilder sb = new StringBuilder(200);
  603. +       sb.append("<table>");
  604. +      
  605. +       for (Map.Entry<String, ArrayList<Integer>> scheme : schemes.entrySet())
  606. +       {
  607. +           if (schemeName.equalsIgnoreCase(scheme.getKey()))
  608. +               StringUtil.append(sb, "<tr><td width=200>", scheme.getKey(), " (<font color=\"LEVEL\">", scheme.getValue().size(), "</font> / ", Config.PBUFFER_MAX_SKILLS, " skill(s))</td></tr>");
  609. +           else
  610. +               StringUtil.append(sb, "<tr><td width=200><a action=\"bypass -h npc_%objectId%_editschemes none ", scheme.getKey(), "\">", scheme.getKey(), " (", scheme.getValue().size(), " / ", Config.PBUFFER_MAX_SKILLS, " skill(s))</a></td></tr>");
  611. +       }
  612. +      
  613. +       sb.append("</table>");
  614. +      
  615. +       return sb.toString();
  616. +   }
  617. +  
  618. +   /**
  619. +    * @param player : The player to make checks on.
  620. +    * @param groupType : The group of skills to select.
  621. +    * @param schemeName : The scheme to make check.
  622. +    * @return a String representing skills available to selection for a given groupType.
  623. +    */
  624. +   private static String getGroupSkillList(Player player, String groupType, String schemeName)
  625. +   {
  626. +       final List<Integer> skills = new ArrayList<>();
  627. +       for (int skillId : BufferManager.getInstance().getSkillsIdsByType(groupType))
  628. +       {
  629. +           if (BufferManager.getInstance().getSchemeContainsSkill(player.getObjectId(), schemeName, skillId))
  630. +               continue;
  631. +          
  632. +           skills.add(skillId);
  633. +       }
  634. +      
  635. +       if (skills.isEmpty())
  636. +           return "That group doesn't contain any skills.";
  637. +      
  638. +       final StringBuilder sb = new StringBuilder(500);
  639. +      
  640. +       sb.append("<table>");
  641. +       int count = 0;
  642. +       for (int skillId : skills)
  643. +       {
  644. +           if (BufferManager.getInstance().getSchemeContainsSkill(player.getObjectId(), schemeName, skillId))
  645. +               continue;
  646. +          
  647. +           if (count == 0)
  648. +               sb.append("<tr>");
  649. +          
  650. +           if (skillId < 100)
  651. +               sb.append("<td width=180><font color=\"949490\"><a action=\"bypass -h npc_%objectId%_skillselect " + groupType + " " + schemeName + " " + skillId + "\">" + SkillTable.getInstance().getInfo(skillId, 1).getName() + "</a></font></td>");
  652. +           else if (skillId < 1000)
  653. +               sb.append("<td width=180><font color=\"949490\"><a action=\"bypass -h npc_%objectId%_skillselect " + groupType + " " + schemeName + " " + skillId + "\">" + SkillTable.getInstance().getInfo(skillId, 1).getName() + "</a></font></td>");
  654. +           else
  655. +               sb.append("<td width=180><font color=\"949490\"><a action=\"bypass -h npc_%objectId%_skillselect " + groupType + " " + schemeName + " " + skillId + "\">" + SkillTable.getInstance().getInfo(skillId, 1).getName() + "</a></font></td>");
  656. +          
  657. +           count++;
  658. +           if (count == 2)
  659. +           {
  660. +               sb.append("</tr><tr><td></td></tr>");
  661. +               count = 0;
  662. +           }
  663. +       }
  664. +      
  665. +       if (!sb.toString().endsWith("</tr>"))
  666. +           sb.append("</tr>");
  667. +      
  668. +       sb.append("</table>");
  669. +      
  670. +       return sb.toString();
  671. +   }
  672. +  
  673. +   /**
  674. +    * @param player : The player to make checks on.
  675. +    * @param groupType : The group of skills to select.
  676. +    * @param schemeName : The scheme to make check.
  677. +    * @return a String representing a given scheme's content.
  678. +    */
  679. +   private static String getPlayerSchemeSkillList(Player player, String groupType, String schemeName)
  680. +   {
  681. +       final List<Integer> skills = BufferManager.getInstance().getScheme(player.getObjectId(), schemeName);
  682. +       if (skills.isEmpty())
  683. +           return "That scheme is empty.";
  684. +      
  685. +       final StringBuilder sb = new StringBuilder(500);
  686. +       sb.append("<table>");
  687. +       int count = 0;
  688. +      
  689. +       for (int sk : skills)
  690. +       {
  691. +           if (count == 0)
  692. +               sb.append("<tr>");
  693. +          
  694. +           if (sk < 100)
  695. +               sb.append("<td width=180><font color=\"6e6e6a\"><a action=\"bypass -h npc_%objectId%_skillunselect " + groupType + " " + schemeName + " " + sk + "\">" + SkillTable.getInstance().getInfo(sk, 1).getName() + "</a></font></td>");
  696. +           else if (sk < 1000)
  697. +               sb.append("<td width=180><font color=\"6e6e6a\"><a action=\"bypass -h npc_%objectId%_skillunselect " + groupType + " " + schemeName + " " + sk + "\">" + SkillTable.getInstance().getInfo(sk, 1).getName() + "</a></font></td>");
  698. +           else
  699. +               sb.append("<td width=180><font color=\"6e6e6a\"><a action=\"bypass -h npc_%objectId%_skillunselect " + groupType + " " + schemeName + " " + sk + "\">" + SkillTable.getInstance().getInfo(sk, 1).getName() + "</a></font></td>");
  700. +          
  701. +           count++;
  702. +           if (count == 2)
  703. +           {
  704. +               sb.append("</tr><tr><td></td></tr>");
  705. +               count = 0;
  706. +           }
  707. +       }
  708. +      
  709. +       if (!sb.toString().endsWith("<tr>"))
  710. +           sb.append("<tr>");
  711. +      
  712. +       sb.append("</table>");
  713. +      
  714. +       return sb.toString();
  715. +   }
  716. +  
  717. +   /**
  718. +    * @param groupType : The group of skills to select.
  719. +    * @param schemeName : The scheme to make check.
  720. +    * @return a string representing all groupTypes availables. The group currently on selection isn't linkable.
  721. +    */
  722. +   private static String getTypesFrame(String groupType, String schemeName)
  723. +   {
  724. +       final StringBuilder sb = new StringBuilder(500);
  725. +       sb.append("<table>");
  726. +      
  727. +       int count = 0;
  728. +       for (String s : BufferManager.getInstance().getSkillTypes())
  729. +       {
  730. +           if (count == 0)
  731. +               sb.append("<tr>");
  732. +          
  733. +           if (groupType.equalsIgnoreCase(s))
  734. +               StringUtil.append(sb, "<td width=65>", s, "</td>");
  735. +           else
  736. +               StringUtil.append(sb, "<td width=65><a action=\"bypass -h npc_%objectId%_editschemes ", s, " ", schemeName, "\">", s, "</a></td>");
  737. +          
  738. +           count++;
  739. +           if (count == 4)
  740. +           {
  741. +               sb.append("</tr>");
  742. +               count = 0;
  743. +           }
  744. +       }
  745. +      
  746. +       if (!sb.toString().endsWith("</tr>"))
  747. +           sb.append("</tr>");
  748. +      
  749. +       sb.append("</table>");
  750. +      
  751. +       return sb.toString();
  752. +   }
  753. +  
  754. +   /**
  755. +    * @param list : A list of skill ids.
  756. +    * @return a global fee for all skills contained in list.
  757. +    */
  758. +   private static int getFee(ArrayList<Integer> list)
  759. +   {
  760. +       if (Config.PBUFFER_STATIC_BUFF_COST >= 0)
  761. +           return (list.size() * Config.PBUFFER_STATIC_BUFF_COST);
  762. +      
  763. +       int fee = 0;
  764. +       for (int sk : list)
  765. +       {
  766. +           if (Config.PBUFFER_BUFFLIST.get(sk) == null)
  767. +               continue;
  768. +          
  769. +           fee += Config.PBUFFER_BUFFLIST.get(sk).getValue();
  770. +       }
  771. +      
  772. +       return fee;
  773. +   }
  774. +  
  775. +   private void autoBuffFunction(Player player, String bufflist)
  776. +   {
  777. +       ArrayList<L2Skill> skills_to_buff = new ArrayList<>();
  778. +       List<Integer> list = null;
  779. +      
  780. +       if (bufflist.equalsIgnoreCase("fighter"))
  781. +           list = Config.PFIGHTER_SKILL_LIST;
  782. +       else if (bufflist.equalsIgnoreCase("mage"))
  783. +           list = Config.PMAGE_SKILL_LIST;
  784. +      
  785. +       if (list != null)
  786. +       {
  787. +           for (int skillId : list)
  788. +           {
  789. +               L2Skill skill = SkillTable.getInstance().getInfo(skillId, SkillTable.getInstance().getMaxLevel(skillId));
  790. +               if (skill != null)
  791. +                   skills_to_buff.add(skill);
  792. +           }
  793. +          
  794. +           for (L2Skill sk : skills_to_buff)
  795. +               sk.getEffects(player, player);
  796. +          
  797. +           player.updateEffectIcons();
  798. +          
  799. +           list = null;
  800. +       }
  801. +      
  802. +       skills_to_buff.clear();
  803. +      
  804. +       showMainWindow(player);
  805. +   }
  806. +}
  807. \ No newline at end of file
  808.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement