RequestGetItemFromPet.java 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 com.l2jserver.gameserver.network.clientpackets;
  16. import java.util.logging.Logger;
  17. import com.l2jserver.Config;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
  20. import com.l2jserver.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 long _amount;
  32. @SuppressWarnings("unused")
  33. private int _unknown;
  34. @Override
  35. protected void readImpl()
  36. {
  37. _objectId = readD();
  38. _amount = readQ();
  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))
  46. return;
  47. if (!getClient().getFloodProtectors().getTransaction().tryPerformAction("getfrompet"))
  48. {
  49. player.sendMessage("You get items from pet too fast.");
  50. return;
  51. }
  52. L2PetInstance pet = (L2PetInstance) player.getPet();
  53. if (player.getActiveEnchantItem() != null)
  54. return;
  55. if (_amount < 0)
  56. {
  57. Util.handleIllegalPlayerAction(player, "[RequestGetItemFromPet] Character " + player.getName() + " of account " + player.getAccountName() + " tried to get item with oid " + _objectId + " from pet but has count < 0!", Config.DEFAULT_PUNISH);
  58. return;
  59. }
  60. else if (_amount == 0)
  61. return;
  62. if (pet.transferItem("Transfer", _objectId, _amount, player.getInventory(), player, pet) == null)
  63. {
  64. _log.warning("Invalid item transfer request: " + pet.getName() + "(pet) --> " + player.getName());
  65. }
  66. }
  67. @Override
  68. public String getType()
  69. {
  70. return REQUESTGETITEMFROMPET__C__8C;
  71. }
  72. }