Advertisement
xSweeTs

AIO System

May 4th, 2016
1,310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 27.34 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P aCis_gameserver
  3. Index: java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
  4. ===================================================================
  5. --- java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (revision 650)
  6. +++ java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (working copy)
  7. @@ -18,6 +18,7 @@
  8.  import java.util.Map;
  9.  
  10.  import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminAdmin;
  11. +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminAio;
  12.  import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminAnnouncements;
  13.  import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminBan;
  14.  import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminBookmark;
  15. @@ -76,6 +77,7 @@
  16.     protected AdminCommandHandler()
  17.     {
  18.         registerAdminCommandHandler(new AdminAdmin());
  19. +       registerAdminCommandHandler(new AdminAio());
  20.         registerAdminCommandHandler(new AdminAnnouncements());
  21.         registerAdminCommandHandler(new AdminBan());
  22.         registerAdminCommandHandler(new AdminBookmark());
  23. Index: java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
  24. ===================================================================
  25. --- java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java  (revision 650)
  26. +++ java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java  (working copy)
  27. @@ -153,6 +153,12 @@
  28.             return false;
  29.         }
  30.        
  31. +       if (player.isAio())
  32. +       {
  33. +           player.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT);
  34. +           return false;
  35. +       }
  36. +      
  37.         switch (type)
  38.         {
  39.             case CLASSED:
  40. Index: java/net/sf/l2j/gameserver/taskmanager/AioTaskManager.java
  41. ===================================================================
  42. --- java/net/sf/l2j/gameserver/taskmanager/AioTaskManager.java  (nonexistent)
  43. +++ java/net/sf/l2j/gameserver/taskmanager/AioTaskManager.java  (working copy)
  44. @@ -0,0 +1,73 @@
  45. +/*
  46. + * This program is free software: you can redistribute it and/or modify it under
  47. + * the terms of the GNU General Public License as published by the Free Software
  48. + * Foundation, either version 3 of the License, or (at your option) any later
  49. + * version.
  50. + *
  51. + * This program is distributed in the hope that it will be useful, but WITHOUT
  52. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  53. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  54. + * details.
  55. + *
  56. + * You should have received a copy of the GNU General Public License along with
  57. + * this program. If not, see <http://www.gnu.org/licenses/>.
  58. + */
  59. +package net.sf.l2j.gameserver.taskmanager;
  60. +
  61. +import java.util.Map;
  62. +import java.util.concurrent.ConcurrentHashMap;
  63. +
  64. +import net.sf.l2j.commons.concurrent.ThreadPool;
  65. +
  66. +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminAio;
  67. +import net.sf.l2j.gameserver.model.actor.L2Character;
  68. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  69. +
  70. +public final class AioTaskManager implements Runnable
  71. +{
  72. +   private final Map<L2PcInstance, Long> _players = new ConcurrentHashMap<>();
  73. +  
  74. +   protected AioTaskManager()
  75. +   {
  76. +       // Run task each 10 second.
  77. +       ThreadPool.scheduleAtFixedRate(this, 10000, 10000);
  78. +   }
  79. +  
  80. +   public final void add(L2PcInstance player)
  81. +   {
  82. +       _players.put(player, System.currentTimeMillis());
  83. +   }
  84. +  
  85. +   public final void remove(L2Character player)
  86. +   {
  87. +       _players.remove(player);
  88. +   }
  89. +  
  90. +   @Override
  91. +   public final void run()
  92. +   {
  93. +       if (_players.isEmpty())
  94. +           return;
  95. +      
  96. +       for (Map.Entry<L2PcInstance, Long> entry : _players.entrySet())
  97. +       {
  98. +           final L2PcInstance player = entry.getKey();
  99. +          
  100. +           if (player.getMemos().getLong("aioEndTime") < System.currentTimeMillis())
  101. +           {
  102. +               AdminAio.removeAio(player);
  103. +               remove(player);
  104. +           }
  105. +       }
  106. +   }
  107. +  
  108. +   public static final AioTaskManager getInstance()
  109. +   {
  110. +       return SingletonHolder._instance;
  111. +   }
  112. +  
  113. +   private static class SingletonHolder
  114. +   {
  115. +       protected static final AioTaskManager _instance = new AioTaskManager();
  116. +   }
  117. +}
  118. \ No newline at end of file
  119. Index: java/net/sf/l2j/Config.java
  120. ===================================================================
  121. --- java/net/sf/l2j/Config.java (revision 650)
  122. +++ java/net/sf/l2j/Config.java (working copy)
  123. @@ -483,6 +483,13 @@
  124.     public static boolean STORE_SKILL_COOLTIME;
  125.     public static int BUFFS_MAX_AMOUNT;
  126.    
  127. +   /** AIO System */
  128. +   public static Map<Integer, Integer> AIO_SKILLS;
  129. +   public static int AIO_NICK_COLOR;
  130. +   public static int AIO_TITLE_COLOR;
  131. +   public static int AIO_ITEM_ID;
  132. +   public static int AIO_COIN_DURATION;
  133. +  
  134.     // --------------------------------------------------
  135.     // Sieges
  136.     // --------------------------------------------------
  137. @@ -1185,6 +1192,18 @@
  138.        
  139.         BUFFS_MAX_AMOUNT = players.getProperty("MaxBuffsAmount", 20);
  140.         STORE_SKILL_COOLTIME = players.getProperty("StoreSkillCooltime", true);
  141. +      
  142. +       AIO_NICK_COLOR = Integer.decode("0x" + players.getProperty("AioNameColor", "FFFF00"));
  143. +       AIO_TITLE_COLOR = Integer.decode("0x" + players.getProperty("AioTitleColor", "FFFF00"));
  144. +       AIO_ITEM_ID = players.getProperty("AioItemId", 5233);
  145. +       AIO_COIN_DURATION = players.getProperty("AioCoinDuration", 1);
  146. +      
  147. +       AIO_SKILLS = new HashMap<>();
  148. +       for (String skillInfo : players.getProperty("AioSkills").split(";"))
  149. +       {
  150. +           final String[] info = skillInfo.split(",");
  151. +           AIO_SKILLS.put(Integer.parseInt(info[0]), Integer.parseInt(info[1]));
  152. +       }
  153.     }
  154.    
  155.     /**
  156. Index: java/net/sf/l2j/gameserver/network/serverpackets/CharInfo.java
  157. ===================================================================
  158. --- java/net/sf/l2j/gameserver/network/serverpackets/CharInfo.java  (revision 650)
  159. +++ java/net/sf/l2j/gameserver/network/serverpackets/CharInfo.java  (working copy)
  160. @@ -206,7 +206,7 @@
  161.             writeD(0);
  162.         }
  163.        
  164. -       writeD(_activeChar.getAppearance().getNameColor());
  165. +       writeD(_activeChar.isAio() ? Config.AIO_NICK_COLOR : _activeChar.getAppearance().getNameColor());
  166.        
  167.         writeD(0x00); // isRunning() as in UserInfo?
  168.        
  169. @@ -213,7 +213,7 @@
  170.         writeD(_activeChar.getPledgeClass());
  171.         writeD(_activeChar.getPledgeType());
  172.        
  173. -       writeD(_activeChar.getAppearance().getTitleColor());
  174. +       writeD(_activeChar.isAio() ? Config.AIO_TITLE_COLOR : _activeChar.getAppearance().getTitleColor());
  175.        
  176.         if (_activeChar.isCursedWeaponEquipped())
  177.             writeD(CursedWeaponsManager.getInstance().getCurrentStage(_activeChar.getCursedWeaponEquippedId()) - 1);
  178. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2AioInstance.java
  179. ===================================================================
  180. --- java/net/sf/l2j/gameserver/model/actor/instance/L2AioInstance.java  (nonexistent)
  181. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2AioInstance.java  (working copy)
  182. @@ -0,0 +1,84 @@
  183. +/*
  184. + * This program is free software; you can redistribute it and/or modify
  185. + * it under the terms of the GNU General Public License as published by
  186. + * the Free Software Foundation; either version 2, or (at your option)
  187. + * any later version.
  188. + *
  189. + * This program is distributed in the hope that it will be useful,
  190. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  191. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  192. + * GNU General Public License for more details.
  193. + *
  194. + * You should have received a copy of the GNU General Public License
  195. + * along with this program; if not, write to the Free Software
  196. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  197. + * 02111-1307, USA.
  198. + *
  199. + * http://www.gnu.org/copyleft/gpl.html
  200. + */
  201. +package net.sf.l2j.gameserver.model.actor.instance;
  202. +
  203. +import java.util.StringTokenizer;
  204. +
  205. +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminAio;
  206. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  207. +import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
  208. +import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
  209. +import net.sf.l2j.gameserver.network.SystemMessageId;
  210. +import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  211. +
  212. +public class L2AioInstance extends L2NpcInstance
  213. +{
  214. +   public L2AioInstance(int objectId, NpcTemplate template)
  215. +   {
  216. +       super(objectId, template);
  217. +   }
  218. +  
  219. +   @Override
  220. +   public void onBypassFeedback(L2PcInstance player, String command)
  221. +   {
  222. +       StringTokenizer st = new StringTokenizer(command, " ");
  223. +       String currentCommand = st.nextToken();
  224. +      
  225. +       if (currentCommand.startsWith("buy"))
  226. +       {
  227. +           if (st.countTokens() != 3)
  228. +               return;
  229. +          
  230. +           if (OlympiadManager.getInstance().isRegisteredInComp(player))
  231. +           {
  232. +               player.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT);
  233. +               return;
  234. +           }
  235. +          
  236. +           final int itemId = Integer.parseInt(st.nextToken());
  237. +           final int count = Integer.parseInt(st.nextToken());
  238. +           final int time = Integer.parseInt(st.nextToken());
  239. +          
  240. +           ItemInstance item = player.getInventory().getItemByItemId(itemId);
  241. +          
  242. +           if (item == null || item.getCount() < count)
  243. +           {
  244. +               player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
  245. +               return;
  246. +           }
  247. +          
  248. +           player.destroyItemByItemId("Consume", itemId, count, player, true);
  249. +           AdminAio.doAio(player, time);
  250. +       }
  251. +      
  252. +       super.onBypassFeedback(player, command);
  253. +   }
  254. +  
  255. +   @Override
  256. +   public String getHtmlPath(int npcId, int val)
  257. +   {
  258. +       String filename = "";
  259. +       if (val == 0)
  260. +           filename = "" + npcId;
  261. +       else
  262. +           filename = npcId + "-" + val;
  263. +      
  264. +       return "data/html/mods/aio/" + filename + ".htm";
  265. +   }
  266. +}
  267. \ No newline at end of file
  268. Index: java/net/sf/l2j/gameserver/network/serverpackets/UserInfo.java
  269. ===================================================================
  270. --- java/net/sf/l2j/gameserver/network/serverpackets/UserInfo.java  (revision 650)
  271. +++ java/net/sf/l2j/gameserver/network/serverpackets/UserInfo.java  (working copy)
  272. @@ -264,7 +264,7 @@
  273.             writeD(0);
  274.         }
  275.        
  276. -       writeD(_activeChar.getAppearance().getNameColor());
  277. +       writeD(_activeChar.isAio() ? Config.AIO_NICK_COLOR : _activeChar.getAppearance().getNameColor());
  278.        
  279.         // new c5
  280.         writeC(_activeChar.isRunning() ? 0x01 : 0x00); // changes the Speed display on Status Window
  281. @@ -272,7 +272,7 @@
  282.         writeD(_activeChar.getPledgeClass()); // changes the text above CP on Status Window
  283.         writeD(_activeChar.getPledgeType());
  284.        
  285. -       writeD(_activeChar.getAppearance().getTitleColor());
  286. +       writeD(_activeChar.isAio() ? Config.AIO_TITLE_COLOR : _activeChar.getAppearance().getTitleColor());
  287.        
  288.         if (_activeChar.isCursedWeaponEquipped())
  289.             writeD(CursedWeaponsManager.getInstance().getCurrentStage(_activeChar.getCursedWeaponEquippedId()) - 1);
  290. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2VillageMasterInstance.java
  291. ===================================================================
  292. --- java/net/sf/l2j/gameserver/model/actor/instance/L2VillageMasterInstance.java    (revision 650)
  293. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2VillageMasterInstance.java    (working copy)
  294. @@ -173,6 +173,11 @@
  295.                 player.sendPacket(SystemMessageId.SUBCLASS_NO_CHANGE_OR_CREATE_WHILE_SKILL_IN_USE);
  296.                 return;
  297.             }
  298. +           else if (player.isAio())
  299. +           {
  300. +               player.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT);
  301. +               return;
  302. +           }
  303.            
  304.             // Affecting subclasses (add/del/change) if registered in Olympiads makes you ineligible to compete.
  305.             if (OlympiadManager.getInstance().isRegisteredInComp(player))
  306. Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminAio.java
  307. ===================================================================
  308. --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminAio.java   (nonexistent)
  309. +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminAio.java   (working copy)
  310. @@ -0,0 +1,171 @@
  311. +/*
  312. + * This program is free software; you can redistribute it and/or modify
  313. + * it under the terms of the GNU General Public License as published by
  314. + * the Free Software Foundation; either version 2, or (at your option)
  315. + * any later version.
  316. + *
  317. + * This program is distributed in the hope that it will be useful,
  318. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  319. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  320. + * GNU General Public License for more details.
  321. + *
  322. + * You should have received a copy of the GNU General Public License
  323. + * along with this program; if not, write to the Free Software
  324. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  325. + * 02111-1307, USA.
  326. + *
  327. + * http://www.gnu.org/copyleft/gpl.html
  328. + */
  329. +package net.sf.l2j.gameserver.handler.admincommandhandlers;
  330. +
  331. +import java.util.StringTokenizer;
  332. +import java.util.concurrent.TimeUnit;
  333. +
  334. +import net.sf.l2j.Config;
  335. +import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
  336. +import net.sf.l2j.gameserver.model.L2Skill;
  337. +import net.sf.l2j.gameserver.model.World;
  338. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  339. +import net.sf.l2j.gameserver.network.clientpackets.Say2;
  340. +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  341. +import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
  342. +import net.sf.l2j.gameserver.taskmanager.AioTaskManager;
  343. +
  344. +/**
  345. + * @author SweeTs
  346. + */
  347. +public class AdminAio implements IAdminCommandHandler
  348. +{
  349. +   private static String[] _adminCommands =
  350. +   {
  351. +       "admin_setaio",
  352. +       "admin_removeaio"
  353. +   };
  354. +  
  355. +   @Override
  356. +   public boolean useAdminCommand(String command, L2PcInstance activeChar)
  357. +   {
  358. +       StringTokenizer st = new StringTokenizer(command);
  359. +       st.nextToken();
  360. +       String player = "";
  361. +       int duration = 1;
  362. +       L2PcInstance target = null;
  363. +      
  364. +       // One parameter, player name
  365. +       if (st.hasMoreTokens())
  366. +       {
  367. +           player = st.nextToken();
  368. +           target = World.getInstance().getPlayer(player);
  369. +          
  370. +           // Second parameter, duration
  371. +           if (st.hasMoreTokens())
  372. +           {
  373. +               try
  374. +               {
  375. +                   duration = Integer.parseInt(st.nextToken());
  376. +               }
  377. +               catch (NumberFormatException nfe)
  378. +               {
  379. +                   activeChar.sendMessage("Invalid number format used: " + nfe);
  380. +                   return false;
  381. +               }
  382. +           }
  383. +       }
  384. +       else
  385. +       {
  386. +           // If there is no name, select target
  387. +           if (activeChar.getTarget() != null && activeChar.getTarget() instanceof L2PcInstance)
  388. +               target = (L2PcInstance) activeChar.getTarget();
  389. +       }
  390. +      
  391. +       if (command.startsWith("admin_setaio"))
  392. +       {
  393. +           if (target == null && player.equals(""))
  394. +           {
  395. +               activeChar.sendMessage("Usage: //setaio <char_name> [duration_days]");
  396. +               return false;
  397. +           }
  398. +          
  399. +           if (target != null)
  400. +           {
  401. +               doAio(target, duration);
  402. +               activeChar.sendMessage(target.getName() + " is now an AIO for " + duration + " day(s).");
  403. +           }
  404. +       }
  405. +       else if (command.startsWith("admin_removeaio"))
  406. +       {
  407. +           if (target == null && player.equals(""))
  408. +           {
  409. +               activeChar.sendMessage("Usage: //removeaio <char_name>");
  410. +               return false;
  411. +           }
  412. +          
  413. +           if (target != null)
  414. +           {
  415. +               if (target.isAio())
  416. +               {
  417. +                   removeAio(target);
  418. +                   activeChar.sendMessage(target.getName() + "'s AIO status has been removed.");
  419. +               }
  420. +               else
  421. +                   activeChar.sendMessage(target.getName() + " is not an AIO.");
  422. +           }
  423. +       }
  424. +       return true;
  425. +   }
  426. +  
  427. +   public static void doAio(L2PcInstance target, int time)
  428. +   {
  429. +       target.getStat().addExp(target.getStat().getExpForLevel(81));
  430. +       target.broadcastPacket(new SocialAction(target, 3));
  431. +       target.setAio(true);
  432. +       AioTaskManager.getInstance().add(target);
  433. +      
  434. +       long remainingTime = target.getMemos().getLong("aioEndTime", 0);
  435. +       if (remainingTime > 0)
  436. +       {
  437. +           target.getMemos().set("aioEndTime", remainingTime + TimeUnit.DAYS.toMillis(time));
  438. +           target.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "System", "Dear player, your AIO status has been extended by " + time + " day(s)."));
  439. +       }
  440. +       else
  441. +       {
  442. +           target.getMemos().set("aioEndTime", System.currentTimeMillis() + TimeUnit.DAYS.toMillis(time));
  443. +           target.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "System", "Dear player, you are now an AIO, congratulations."));
  444. +          
  445. +           for (L2Skill skill : target.getSkills().values())
  446. +               target.removeSkill(skill);
  447. +          
  448. +           if (Config.AIO_ITEM_ID != 0)
  449. +           {
  450. +               target.addItem("Add", Config.AIO_ITEM_ID, 1, target, true);
  451. +               target.getInventory().equipItemAndRecord(target.getInventory().getItemByItemId(Config.AIO_ITEM_ID));
  452. +           }
  453. +          
  454. +           target.addAioSkills();
  455. +           target.broadcastUserInfo();
  456. +       }
  457. +   }
  458. +  
  459. +   public static void removeAio(L2PcInstance target)
  460. +   {
  461. +       AioTaskManager.getInstance().remove(target);
  462. +       target.getMemos().set("aioEndTime", 0);
  463. +       target.setAio(false);
  464. +      
  465. +       for (L2Skill skill : target.getSkills().values())
  466. +           target.removeSkill(skill);
  467. +      
  468. +       if (Config.AIO_ITEM_ID != 0)
  469. +           target.destroyItemByItemId("Destroy", Config.AIO_ITEM_ID, 1, target, true);
  470. +      
  471. +       target.sendPacket(new CreatureSay(0, Say2.PARTYROOM_COMMANDER, "System", "Your AIO period is over."));
  472. +       target.broadcastPacket(new SocialAction(target, 13));
  473. +       target.broadcastUserInfo();
  474. +   }
  475. +  
  476. +   @Override
  477. +   public String[] getAdminCommandList()
  478. +   {
  479. +       return _adminCommands;
  480. +   }
  481. +}
  482. \ No newline at end of file
  483. Index: java/net/sf/l2j/gameserver/handler/ItemHandler.java
  484. ===================================================================
  485. --- java/net/sf/l2j/gameserver/handler/ItemHandler.java (revision 650)
  486. +++ java/net/sf/l2j/gameserver/handler/ItemHandler.java (working copy)
  487. @@ -17,6 +17,7 @@
  488.  import java.util.HashMap;
  489.  import java.util.Map;
  490.  
  491. +import net.sf.l2j.gameserver.handler.itemhandlers.AioCoin;
  492.  import net.sf.l2j.gameserver.handler.itemhandlers.BeastSoulShot;
  493.  import net.sf.l2j.gameserver.handler.itemhandlers.BeastSpice;
  494.  import net.sf.l2j.gameserver.handler.itemhandlers.BeastSpiritShot;
  495. @@ -56,6 +57,7 @@
  496.    
  497.     protected ItemHandler()
  498.     {
  499. +       registerItemHandler(new AioCoin());
  500.         registerItemHandler(new BeastSoulShot());
  501.         registerItemHandler(new BeastSpice());
  502.         registerItemHandler(new BeastSpiritShot());
  503. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
  504. ===================================================================
  505. --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (revision 650)
  506. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (working copy)
  507. @@ -243,6 +243,7 @@
  508.  import net.sf.l2j.gameserver.skills.funcs.FuncMaxCpMul;
  509.  import net.sf.l2j.gameserver.skills.l2skills.L2SkillSiegeFlag;
  510.  import net.sf.l2j.gameserver.skills.l2skills.L2SkillSummon;
  511. +import net.sf.l2j.gameserver.taskmanager.AioTaskManager;
  512.  import net.sf.l2j.gameserver.taskmanager.AttackStanceTaskManager;
  513.  import net.sf.l2j.gameserver.taskmanager.GameTimeTaskManager;
  514.  import net.sf.l2j.gameserver.taskmanager.ItemsOnGroundTaskManager;
  515. @@ -466,6 +467,7 @@
  516.    
  517.     private boolean _isNoble;
  518.     private boolean _isHero;
  519. +   private boolean _isAio;
  520.    
  521.     private L2Npc _currentFolkNpc;
  522.    
  523. @@ -1931,7 +1933,7 @@
  524.         }
  525.        
  526.         // Auto-Learn skills if activated
  527. -       if (Config.AUTO_LEARN_SKILLS)
  528. +       if (Config.AUTO_LEARN_SKILLS && !isAio())
  529.             giveAvailableSkills();
  530.        
  531.         sendSkillList();
  532. @@ -4330,6 +4332,7 @@
  533.         PvpFlagTaskManager.getInstance().remove(this);
  534.         GameTimeTaskManager.getInstance().remove(this);
  535.         ShadowItemTaskManager.getInstance().remove(this);
  536. +       AioTaskManager.getInstance().remove(this);
  537.     }
  538.    
  539.     /**
  540. @@ -6576,6 +6579,12 @@
  541.             return false;
  542.         }
  543.        
  544. +       if (isAio() && !isGM() && !isInsideZone(ZoneId.TOWN))
  545. +       {
  546. +           sendPacket(ActionFailed.STATIC_PACKET);
  547. +           return false;
  548. +       }
  549. +      
  550.         // Cancels the use of skills when player uses a cursed weapon or is flying.
  551.         if ((isCursedWeaponEquipped() && !skill.isDemonicSkill()) // If CW, allow ONLY demonic skills.
  552.             || (getMountType() == 1 && !skill.isStriderSkill()) // If mounted, allow ONLY Strider skills.
  553. @@ -8123,6 +8132,9 @@
  554.             if (isWearingFormalWear)
  555.                 isDisabled = true;
  556.            
  557. +           if (isAio() && !isGM() && !isInsideZone(ZoneId.TOWN))
  558. +               isDisabled = true;
  559. +          
  560.             sl.addSkill(s.getId(), s.getLevel(), s.isPassive(), isDisabled);
  561.         }
  562.         sendPacket(sl);
  563. @@ -8451,6 +8463,9 @@
  564.         if (isCursedWeaponEquipped())
  565.             CursedWeaponsManager.getInstance().getCursedWeapon(getCursedWeaponEquippedId()).cursedOnLogin();
  566.        
  567. +       if (isAio())
  568. +           AioTaskManager.getInstance().add(this);
  569. +      
  570.         // Add to the GameTimeTask to keep inform about activity time.
  571.         GameTimeTaskManager.getInstance().add(this);
  572.        
  573. @@ -10598,4 +10613,26 @@
  574.             }
  575.         }
  576.     }
  577. +  
  578. +   public boolean isAio()
  579. +   {
  580. +       return _isAio;
  581. +   }
  582. +  
  583. +   public void setAio(boolean b)
  584. +   {
  585. +       _isAio = b;
  586. +   }
  587. +  
  588. +   public void addAioSkills()
  589. +   {
  590. +       for (int skillid : Config.AIO_SKILLS.keySet())
  591. +       {
  592. +           final L2Skill skill = SkillTable.getInstance().getInfo(skillid, Config.AIO_SKILLS.get(skillid));
  593. +          
  594. +           if (skill != null)
  595. +               addSkill(skill, true);
  596. +       }
  597. +       sendSkillList();
  598. +   }
  599.  }
  600. \ No newline at end of file
  601. Index: java/net/sf/l2j/gameserver/handler/itemhandlers/AioCoin.java
  602. ===================================================================
  603. --- java/net/sf/l2j/gameserver/handler/itemhandlers/AioCoin.java    (nonexistent)
  604. +++ java/net/sf/l2j/gameserver/handler/itemhandlers/AioCoin.java    (working copy)
  605. @@ -0,0 +1,45 @@
  606. +/*
  607. + * This program is free software: you can redistribute it and/or modify it under
  608. + * the terms of the GNU General Public License as published by the Free Software
  609. + * Foundation, either version 3 of the License, or (at your option) any later
  610. + * version.
  611. + *
  612. + * This program is distributed in the hope that it will be useful, but WITHOUT
  613. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  614. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  615. + * details.
  616. + *
  617. + * You should have received a copy of the GNU General Public License along with
  618. + * this program. If not, see <http://www.gnu.org/licenses/>.
  619. + */
  620. +package net.sf.l2j.gameserver.handler.itemhandlers;
  621. +
  622. +import net.sf.l2j.Config;
  623. +import net.sf.l2j.gameserver.handler.IItemHandler;
  624. +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminAio;
  625. +import net.sf.l2j.gameserver.model.actor.L2Playable;
  626. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  627. +import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
  628. +import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
  629. +import net.sf.l2j.gameserver.network.SystemMessageId;
  630. +
  631. +public class AioCoin implements IItemHandler
  632. +{
  633. +   @Override
  634. +   public void useItem(L2Playable playable, ItemInstance item, boolean forceUse)
  635. +   {
  636. +       if (!(playable instanceof L2PcInstance))
  637. +           return;
  638. +      
  639. +       L2PcInstance activeChar = (L2PcInstance) playable;
  640. +      
  641. +       if (activeChar.isInOlympiadMode() || OlympiadManager.getInstance().isRegisteredInComp(activeChar))
  642. +       {
  643. +           activeChar.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT);
  644. +           return;
  645. +       }
  646. +      
  647. +       activeChar.destroyItem("Consume", item.getObjectId(), 1, null, true);
  648. +       AdminAio.doAio(activeChar, Config.AIO_COIN_DURATION);
  649. +   }
  650. +}
  651. \ No newline at end of file
  652. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java
  653. ===================================================================
  654. --- java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java  (revision 650)
  655. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java  (working copy)
  656. @@ -81,6 +81,12 @@
  657.             return;
  658.         }
  659.        
  660. +       if (player.isAio())
  661. +       {
  662. +           player.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT);
  663. +           return;
  664. +       }
  665. +      
  666.         AcquireSkillList asl = new AcquireSkillList(AcquireSkillList.SkillType.Usual);
  667.         boolean empty = true;
  668.        
  669. Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  670. ===================================================================
  671. --- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java    (revision 650)
  672. +++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java    (working copy)
  673. @@ -17,6 +17,7 @@
  674.  import java.sql.Connection;
  675.  import java.sql.PreparedStatement;
  676.  import java.sql.ResultSet;
  677. +import java.util.Calendar;
  678.  import java.util.Map.Entry;
  679.  import java.util.logging.Level;
  680.  
  681. @@ -28,6 +29,7 @@
  682.  import net.sf.l2j.gameserver.datatables.GmListTable;
  683.  import net.sf.l2j.gameserver.datatables.MapRegionTable.TeleportWhereType;
  684.  import net.sf.l2j.gameserver.datatables.SkillTable.FrequentSkill;
  685. +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminAio;
  686.  import net.sf.l2j.gameserver.instancemanager.CastleManager;
  687.  import net.sf.l2j.gameserver.instancemanager.ClanHallManager;
  688.  import net.sf.l2j.gameserver.instancemanager.CoupleManager;
  689. @@ -240,6 +242,9 @@
  690.         activeChar.sendPacket(new EtcStatusUpdate(activeChar));
  691.         activeChar.sendSkillList();
  692.        
  693. +       if (activeChar.getMemos().getLong("aioEndTime", 0) > 0)
  694. +           onEnter(activeChar);
  695. +      
  696.         // Load quests.
  697.         try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  698.         {
  699. @@ -339,6 +344,35 @@
  700.         activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  701.     }
  702.    
  703. +   private static void onEnter(L2PcInstance activeChar)
  704. +   {
  705. +       final long now = Calendar.getInstance().getTimeInMillis();
  706. +       final long endDay = activeChar.getMemos().getLong("aioEndTime");
  707. +      
  708. +       if (now > endDay)
  709. +           AdminAio.removeAio(activeChar);
  710. +       else
  711. +       {
  712. +           activeChar.setAio(true);
  713. +           activeChar.broadcastUserInfo();
  714. +           sendReEnterMessage(endDay, activeChar);
  715. +       }
  716. +   }
  717. +  
  718. +   private static void sendReEnterMessage(long time, L2PcInstance activeChar)
  719. +   {
  720. +       final long remainingTime = (time - System.currentTimeMillis()) / 1000;
  721. +       final int hours = (int) (remainingTime / 3600);
  722. +       final int minutes = (int) ((remainingTime % 3600) / 60);
  723. +       final int seconds = (int) ((remainingTime % 3600) % 60);
  724. +      
  725. +       String msg = "Your AIO period ends after: %hours% hours, %mins% minutes and %secs% seconds!";
  726. +       msg = msg.replaceAll("%hours%", Integer.toString(hours));
  727. +       msg = msg.replaceAll("%mins%", Integer.toString(minutes));
  728. +       msg = msg.replaceAll("%secs%", Integer.toString(seconds));
  729. +       activeChar.sendMessage(msg);
  730. +   }
  731. +  
  732.     @Override
  733.     protected boolean triggersOnActionRequest()
  734.     {
  735. Index: config/players.properties
  736. ===================================================================
  737. --- config/players.properties   (revision 650)
  738. +++ config/players.properties   (working copy)
  739. @@ -291,4 +291,34 @@
  740.  MaxBuffsAmount = 20
  741.  
  742.  # Store buffs/debuffs on user logout?
  743. -StoreSkillCooltime = True
  744. \ No newline at end of file
  745. +StoreSkillCooltime = True
  746. +
  747. +#=============================================================
  748. +#                        AIO System
  749. +#=============================================================
  750. +
  751. +# Name color
  752. +AioNameColor = FFFF00
  753. +
  754. +# Title color
  755. +AioTitleColor = FFFF00
  756. +
  757. +# ID of the item that will be given to AIO
  758. +# Default: Keshanberk*Keshanberk
  759. +# 0 to disable
  760. +AioItemId = 5233
  761. +
  762. +# Time in days
  763. +AioCoinDuration = 1
  764. +
  765. +# List of Aio Skills
  766. +# Format : skillid,skilllvl;skillid2,skilllvl2;
  767. +AioSkills = 1085,3;1304,3;1087,3;1354,1;1062,2;1243,6;1045,6;1048,6;1429,1;163,1;\
  768. +1311,6;213,8;1007,3;1309,3;1552,3;1006,3;1308,3;1253,3;1284,3;1392,3;1393,3;214,1;\
  769. +1009,3;1310,4;1363,1;1362,1;1397,3;1292,6;1078,6;307,1;276,1;309,1;274,1;275,1;164,3;\
  770. +272,1;277,1;273,1;311,1;366,1;365,1;310,1;271,1;1242,3;1353,3;1391,3;1002,3;7029,1;\
  771. +1352,1;229,7;228,3;1077,3;1218,33;1059,3;1219,33;1388,3;1389,3;1240,3;1413,1;\
  772. +1086,2;1036,2;1035,4;1068,3;1356,1;1355,1;1357,1;1307,3;1410,1;1409,1;1353,1;\
  773. +1044,3;1182,3;1191,3;1189,3;1259,4;1306,6;234,23;1040,3;364,1;264,1;306,1;\
  774. +269,1;270,1;265,1;363,1;349,1;308,1;305,1;304,1;267,1;266,1;268,1;1390,3;1303,2;\
  775. +1204,2;1268,4
  776. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement