L2ItemInstanceAction.java 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 handlers.actionhandlers;
  16. import com.l2jserver.gameserver.ai.CtrlIntention;
  17. import com.l2jserver.gameserver.handler.IActionHandler;
  18. import com.l2jserver.gameserver.instancemanager.MercTicketManager;
  19. import com.l2jserver.gameserver.model.L2Object;
  20. import com.l2jserver.gameserver.model.L2Object.InstanceType;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.model.item.instance.L2ItemInstance;
  23. public class L2ItemInstanceAction implements IActionHandler
  24. {
  25. public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
  26. {
  27. // this causes the validate position handler to do the pickup if the location is reached.
  28. // mercenary tickets can only be picked up by the castle owner.
  29. final int castleId = MercTicketManager.getInstance().getTicketCastleId(((L2ItemInstance)target).getItemId());
  30. if (castleId > 0 && (!activeChar.isCastleLord(castleId) || activeChar.isInParty()))
  31. {
  32. if (activeChar.isInParty()) //do not allow owner who is in party to pick tickets up
  33. activeChar.sendMessage("You cannot pickup mercenaries while in a party.");
  34. else
  35. activeChar.sendMessage("Only the castle lord can pickup mercenaries.");
  36. activeChar.setTarget(target);
  37. activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  38. }
  39. else if (!activeChar.isFlying()) // cannot pickup
  40. activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_PICK_UP, target);
  41. return true;
  42. }
  43. public InstanceType getInstanceType()
  44. {
  45. return InstanceType.L2ItemInstance;
  46. }
  47. }