RequestPetGetItem.java 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 net.sf.l2j.gameserver.clientpackets;
  16. import net.sf.l2j.gameserver.ai.CtrlIntention;
  17. import net.sf.l2j.gameserver.model.L2ItemInstance;
  18. import net.sf.l2j.gameserver.model.L2World;
  19. import net.sf.l2j.gameserver.model.actor.instance.L2PetInstance;
  20. import net.sf.l2j.gameserver.model.actor.instance.L2SummonInstance;
  21. import net.sf.l2j.gameserver.serverpackets.ActionFailed;
  22. /**
  23. * This class ...
  24. *
  25. * @version $Revision: 1.2.4.4 $ $Date: 2005/03/29 23:15:33 $
  26. */
  27. public final class RequestPetGetItem extends L2GameClientPacket
  28. {
  29. //private static Logger _log = Logger.getLogger(RequestPetGetItem.class.getName());
  30. private static final String _C__8f_REQUESTPETGETITEM= "[C] 8F RequestPetGetItem";
  31. private int _objectId;
  32. @Override
  33. protected void readImpl()
  34. {
  35. _objectId = readD();
  36. }
  37. @Override
  38. protected void runImpl()
  39. {
  40. L2World world = L2World.getInstance();
  41. L2ItemInstance item = (L2ItemInstance)world.findObject(_objectId);
  42. if (item == null || getClient().getActiveChar() == null)
  43. return;
  44. if(getClient().getActiveChar().getPet() instanceof L2SummonInstance)
  45. {
  46. sendPacket(ActionFailed.STATIC_PACKET);
  47. return;
  48. }
  49. L2PetInstance pet = (L2PetInstance)getClient().getActiveChar().getPet();
  50. if (pet == null || pet.isDead() || pet.isOutOfControl())
  51. {
  52. sendPacket(ActionFailed.STATIC_PACKET);
  53. return;
  54. }
  55. pet.getAI().setIntention(CtrlIntention.AI_INTENTION_PICK_UP, item);
  56. }
  57. @Override
  58. public String getType()
  59. {
  60. return _C__8f_REQUESTPETGETITEM;
  61. }
  62. }