RequestGetItemFromPet.java 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 java.util.logging.Logger;
  17. import net.sf.l2j.Config;
  18. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  19. import net.sf.l2j.gameserver.model.actor.instance.L2PetInstance;
  20. import net.sf.l2j.gameserver.util.Util;
  21. /**
  22. * This class ...
  23. *
  24. * @version $Revision: 1.3.4.4 $ $Date: 2005/03/29 23:15:33 $
  25. */
  26. public final class RequestGetItemFromPet extends L2GameClientPacket
  27. {
  28. private static final String REQUESTGETITEMFROMPET__C__8C = "[C] 8C RequestGetItemFromPet";
  29. private static Logger _log = Logger.getLogger(RequestGetItemFromPet.class.getName());
  30. private int _objectId;
  31. private int _amount;
  32. @SuppressWarnings("unused")
  33. private int _unknown;
  34. @Override
  35. protected void readImpl()
  36. {
  37. _objectId = readD();
  38. _amount = readD();
  39. _unknown = readD();// = 0 for most trades
  40. }
  41. @Override
  42. protected void runImpl()
  43. {
  44. L2PcInstance player = getClient().getActiveChar();
  45. if (player == null || !(player.getPet() instanceof L2PetInstance)) return;
  46. L2PetInstance pet = (L2PetInstance)player.getPet();
  47. if(_amount < 0)
  48. {
  49. Util.handleIllegalPlayerAction(player,"[RequestGetItemFromPet] count < 0! ban! oid: "+_objectId+" owner: "+player.getName(),Config.DEFAULT_PUNISH);
  50. return;
  51. }
  52. else if(_amount == 0)
  53. return;
  54. if (pet.transferItem("Transfer", _objectId, _amount, player.getInventory(), player, pet) == null)
  55. {
  56. _log.warning("Invalid item transfer request: " + pet.getName() + "(pet) --> " + player.getName());
  57. }
  58. }
  59. @Override
  60. public String getType()
  61. {
  62. return REQUESTGETITEMFROMPET__C__8C;
  63. }
  64. }