/* * 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 2, 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, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. * * [URL]http://www.gnu.org/copyleft/gpl.html[/URL] */ package net.sf.l2j.gameserver.handler.itemhandlers; public class EnergyStone implements IItemHandler { private static int[] _itemIds = { 5589}; int num_charges; public void useItem(L2PlayableInstance playable, L2ItemInstance item) { if (!(playable instanceof L2PcInstance)) return; L2PcInstance activeChar = (L2PcInstance)playable; L2Potion potion = new L2Potion(IdFactory.getInstance().getNextId()); int itemId = item.getItemId(); if (itemId == 5589) { if ((activeChar.getClassId().getId() == 2) || (activeChar.getClassId().getId() == 48)) { num_charges = (activeChar.getClassId().getId() == 2) ? activeChar.getSkillLevel(8) : activeChar.getSkillLevel(50); EffectCharge effect = (activeChar.getClassId().getId() == 2) ? (EffectCharge)activeChar.getEffect(8) : (EffectCharge)activeChar.getEffect(50); if (effect != null) { if (effect.getLevel() < num_charges) { MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2165, 1, 1, 0); activeChar.sendPacket(MSU); activeChar.broadcastPacket(MSU); effect.num_charges++; activeChar.updateEffectIcons(); potion.setCurrentMpPotion1(playable, itemId); playable.removeItemFromInventory(item, 1); activeChar.sendMessage("Sonic charged."); }else{ activeChar.sendMessage("Maximum amount of Sonics charged."); } } }else{ activeChar.sendMessage("Only Gladiators or Tyrants can use Energy Stone."); } } } public int[] getItemIds() { return _itemIds; } }