Advertisement
Guest User

[Share]Refresh time(buffs) By AbsolutePower item

a guest
Aug 19th, 2012
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.35 KB | None | 0 0
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package net.sf.l2j.gameserver.handler.itemhandlers;
  16.  
  17. import javolution.util.FastList;
  18.  
  19. import net.sf.l2j.gameserver.datatables.SkillTable;
  20. import net.sf.l2j.gameserver.handler.IItemHandler;
  21. import net.sf.l2j.gameserver.model.L2Effect;
  22. import net.sf.l2j.gameserver.model.L2ItemInstance;
  23. import net.sf.l2j.gameserver.model.L2Skill;
  24. import net.sf.l2j.gameserver.model.actor.L2Playable;
  25. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  26. import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate;
  27. import net.sf.l2j.gameserver.network.serverpackets.SkillCoolTime;
  28. import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
  29. import net.sf.l2j.gameserver.templates.skills.L2SkillType;
  30.  
  31. /**
  32. * @author AbsolutePower
  33. */
  34. public class RefreshItem implements IItemHandler
  35. {
  36. final FastList<L2Effect> Buffs = new FastList<L2Effect>();
  37.  
  38. @Override
  39. public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
  40. {
  41. if (!(playable instanceof L2PcInstance))
  42. return;
  43.  
  44. final L2PcInstance activeChar = (L2PcInstance) playable;
  45. final int itemId = item.getItemId();
  46. final int AdenaID = 57;
  47. final int ItemForUseId = 34;
  48. final int AdenaCount = 100;
  49. final boolean CheckAdena = activeChar.getInventory().getItemByItemId(AdenaID) == null || activeChar.getInventory().getItemByItemId(AdenaID).getCount() < AdenaCount;
  50.  
  51. if (itemId == ItemForUseId)
  52. {
  53. if(CheckAdena)
  54. {
  55. activeChar.sendMessage("You don't have enough adena!");
  56. return;
  57. }
  58. else if(activeChar.isInCombat() || activeChar.getPvpFlag() >0)
  59. {
  60. activeChar.sendMessage("You can't refresh your buffs while you are in combat");
  61. return;
  62. }
  63. else if(activeChar.getKarma() >0)
  64. {
  65. activeChar.sendMessage("You can't refresh your buffs while you got pk");
  66. return;
  67. }
  68. else
  69. activeChar.destroyItem("Item", ItemForUseId, 1, null, false);
  70. activeChar.destroyItem("Adena", AdenaID, AdenaCount, null, false);
  71.  
  72. final L2Effect[] ae = activeChar.getAllEffects();
  73. for(L2Effect p: ae)
  74. {
  75. L2Skill k = SkillTable.getInstance().getInfo(p.getSkill().getId(), p.getLevel());
  76.  
  77. if(k != null && k.getSkillType() == L2SkillType.BUFF)
  78. addBuffs(p);
  79. p.exit();
  80. getBuffs();
  81. k.getEffects(activeChar, activeChar);
  82. activeChar.sendPacket(new InventoryUpdate());
  83. activeChar.sendPacket(new SkillCoolTime(activeChar));
  84. activeChar.sendPacket(new StatusUpdate(activeChar));
  85. activeChar.sendMessage("Your buffs has been refreshed");
  86. }
  87. }
  88. }
  89.  
  90. private FastList<L2Effect> getBuffs()
  91. {
  92. return Buffs;
  93. }
  94.  
  95. private final void addBuffs(L2Effect j)
  96. {
  97. Buffs.add(j);
  98. }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement