afto m exei otan anigo to HeroCustomItem.java
* 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 com.equal.gameserver.handler.itemhandlers;
import com.equal.Config;
import com.equal.gameserver.handler.IItemHandler;
import com.equal.gameserver.model.L2ItemInstance;
import com.equal.gameserver.model.actor.instance.L2PcInstance;
import com.equal.gameserver.model.actor.instance.L2PlayableInstance;
import com.equal.gameserver.network.serverpackets.ActionFailed;
import com.equal.gameserver.network.serverpackets.SocialAction;
public class HeroCustomItem
implements IItemHandler
{
public HeroCustomItem()
{
}
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if(Config.HERO_CUSTOM_ITEMS)
{
if(!(playable instanceof L2PcInstance))
return;
L2PcInstance activeChar = (L2PcInstance)playable;
if (activeChar.isInOlympiadMode())
{
activeChar.sendPacket(new ActionFailed());
}
if (activeChar.isAlikeDead())
{
activeChar.sendPacket(new ActionFailed());
}
if (activeChar.isFestivalParticipant())
{
activeChar.sendPacket(new ActionFailed());
}
if (activeChar.isSilentMoving())
{
activeChar.sendPacket(new ActionFailed());
}
if (activeChar.isDead())
{
activeChar.sendPacket(new ActionFailed());
}
if (activeChar.isConfused())
{
activeChar.sendPacket(new ActionFailed());
}
if (activeChar.inObserverMode())
{
activeChar.sendPacket(new ActionFailed());
}
if (Config.ALLOW_USE_HERO_ITEM_ON_EVENTS)
{
if (activeChar.isInFunEvent())
{
activeChar.sendPacket(new ActionFailed());
}
}
if (Config.ALLOW_USE_HERO_ITEM_ON_SUBCLASS)
{
if (activeChar.isSubClassActive())
{
activeChar.sendPacket(new ActionFailed());
}
}
if(activeChar.isHero())
{
activeChar.sendMessage("You Are Already A Hero!.");
}
else
{
activeChar.broadcastPacket(new SocialAction(activeChar.getObjectId(), 16));
activeChar.setHero(true);
activeChar.sendMessage("You Are Now a Hero,You Are Granted With Hero Status , And Hero Skills.");
activeChar.broadcastUserInfo();
playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
activeChar.getInventory().addItem("Wings", 6842, 1, activeChar, null);
}
}
}
public int[] getItemIds()
{
return ITEM_IDS;
}
private static final int ITEM_IDS[] = {
Config.HERO_ITEM_ID
};
}
ti na kanw??