Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program. If not, see <http://www.gnu.org/licenses/>.
- */
- package net.sf.l2j.gameserver.handler.itemhandlers;
- import javolution.util.FastList;
- import net.sf.l2j.gameserver.datatables.SkillTable;
- import net.sf.l2j.gameserver.handler.IItemHandler;
- import net.sf.l2j.gameserver.model.L2Effect;
- import net.sf.l2j.gameserver.model.L2ItemInstance;
- import net.sf.l2j.gameserver.model.L2Skill;
- import net.sf.l2j.gameserver.model.actor.L2Playable;
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate;
- import net.sf.l2j.gameserver.network.serverpackets.SkillCoolTime;
- import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
- import net.sf.l2j.gameserver.templates.skills.L2SkillType;
- /**
- * @author AbsolutePower
- */
- public class RefreshItem implements IItemHandler
- {
- final FastList<L2Effect> Buffs = new FastList<L2Effect>();
- @Override
- public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
- {
- if (!(playable instanceof L2PcInstance))
- return;
- final L2PcInstance activeChar = (L2PcInstance) playable;
- final int itemId = item.getItemId();
- final int AdenaID = 57;
- final int ItemForUseId = 34;
- final int AdenaCount = 100;
- final boolean CheckAdena = activeChar.getInventory().getItemByItemId(AdenaID) == null || activeChar.getInventory().getItemByItemId(AdenaID).getCount() < AdenaCount;
- if (itemId == ItemForUseId)
- {
- if(CheckAdena)
- {
- activeChar.sendMessage("You don't have enough adena!");
- return;
- }
- else if(activeChar.isInCombat() || activeChar.getPvpFlag() >0)
- {
- activeChar.sendMessage("You can't refresh your buffs while you are in combat");
- return;
- }
- else if(activeChar.getKarma() >0)
- {
- activeChar.sendMessage("You can't refresh your buffs while you got pk");
- return;
- }
- else
- activeChar.destroyItem("Item", ItemForUseId, 1, null, false);
- activeChar.destroyItem("Adena", AdenaID, AdenaCount, null, false);
- final L2Effect[] ae = activeChar.getAllEffects();
- for(L2Effect p: ae)
- {
- L2Skill k = SkillTable.getInstance().getInfo(p.getSkill().getId(), p.getLevel());
- if(k != null && k.getSkillType() == L2SkillType.BUFF)
- addBuffs(p);
- p.exit();
- getBuffs();
- k.getEffects(activeChar, activeChar);
- activeChar.sendPacket(new InventoryUpdate());
- activeChar.sendPacket(new SkillCoolTime(activeChar));
- activeChar.sendPacket(new StatusUpdate(activeChar));
- activeChar.sendMessage("Your buffs has been refreshed");
- }
- }
- }
- private FastList<L2Effect> getBuffs()
- {
- return Buffs;
- }
- private final void addBuffs(L2Effect j)
- {
- Buffs.add(j);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement