Guest User

[Share]Refresh time(buffs) By AbsolutePower 1

a guest
Aug 18th, 2012
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 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.voicedcommandhandlers;
  16.  
  17.  
  18. import javolution.util.FastList;
  19.  
  20. import net.sf.l2j.gameserver.datatables.SkillTable;
  21. import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
  22. import net.sf.l2j.gameserver.model.L2Effect;
  23. import net.sf.l2j.gameserver.model.L2Skill;
  24. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  25. import net.sf.l2j.gameserver.network.serverpackets.SkillCoolTime;
  26. import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
  27. import net.sf.l2j.gameserver.templates.skills.L2SkillType;
  28.  
  29. public class Refresh implements IVoicedCommandHandler
  30. {
  31. private static String[] _voicedCommands =
  32. {
  33. "refresh"
  34. };
  35.  
  36. /**
  37. * @author AbsolutePower
  38. */
  39. @Override
  40. public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
  41. {
  42. if(command.equalsIgnoreCase("refresh"))
  43. {
  44. if(activeChar.isInCombat() || activeChar.getPvpFlag() >0)
  45. {
  46. activeChar.sendMessage("You can't refresh your buffs while you are in combat");
  47. return false;
  48. }
  49. else if(activeChar.getKarma() >0)
  50. {
  51. activeChar.sendMessage("You can't refresh your buffs while you got pk");
  52. return false;
  53. }
  54. else
  55. {
  56. final L2Effect[] ae = activeChar.getAllEffects();
  57. for(L2Effect p: ae)
  58. {
  59. L2Skill k = SkillTable.getInstance().getInfo(p.getSkill().getId(), p.getLevel());
  60.  
  61. if(k != null && k.getSkillType() == L2SkillType.BUFF)
  62. addBuffs(p);
  63. p.exit();
  64. getBuffs();
  65. k.getEffects(activeChar, activeChar);
  66. activeChar.sendPacket(new SkillCoolTime(activeChar));
  67. activeChar.sendPacket(new StatusUpdate(activeChar));
  68. activeChar.sendMessage("Your buffs has been refreshed");
  69. }
  70. }
  71. }
  72. return true;
  73. }
  74.  
  75. final FastList<L2Effect> Buffs = new FastList<L2Effect>();
  76.  
  77. public FastList<L2Effect> getBuffs()
  78. {
  79. return Buffs;
  80. }
  81.  
  82. public final void addBuffs(L2Effect j)
  83. {
  84. Buffs.add(j);
  85. }
  86.  
  87. @Override
  88. public String[] getVoicedCommandList()
  89. {
  90. return _voicedCommands;
  91. }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment