Package handler.items

Source Code of handler.items.Harvester

/*
* 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 handler.items;

import lineage2.gameserver.model.GameObject;
import lineage2.gameserver.model.Player;
import lineage2.gameserver.model.Skill;
import lineage2.gameserver.model.instances.MonsterInstance;
import lineage2.gameserver.model.items.ItemInstance;
import lineage2.gameserver.network.serverpackets.components.SystemMsg;
import lineage2.gameserver.tables.SkillTable;

/**
* @author Mobius
* @version $Revision: 1.0 $
*/
public class Harvester extends SimpleItemHandler
{
  /**
   * Field ITEM_IDS.
   */
  private static final int[] ITEM_IDS = new int[]
  {
    5125
  };
 
  /**
   * Method getItemIds.
   * @return int[] * @see lineage2.gameserver.handler.items.IItemHandler#getItemIds()
   */
  @Override
  public int[] getItemIds()
  {
    return ITEM_IDS;
  }
 
  /**
   * Method useItemImpl.
   * @param player Player
   * @param item ItemInstance
   * @param ctrl boolean
   * @return boolean
   */
  @Override
  protected boolean useItemImpl(Player player, ItemInstance item, boolean ctrl)
  {
    final GameObject target = player.getTarget();
    if ((target == null) || !target.isMonster())
    {
      player.sendPacket(SystemMsg.THAT_IS_AN_INCORRECT_TARGET);
      return false;
    }
    final MonsterInstance monster = (MonsterInstance) player.getTarget();
    if (!monster.isDead())
    {
      player.sendPacket(SystemMsg.THAT_IS_AN_INCORRECT_TARGET);
      return false;
    }
    final Skill skill = SkillTable.getInstance().getInfo(2098, 1);
    if ((skill != null) && skill.checkCondition(player, monster, false, false, true))
    {
      player.getAI().Cast(skill, monster);
      return true;
    }
    return false;
  }
}
TOP

Related Classes of handler.items.Harvester

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.