Freight.java 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright (C) 2004-2014 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J DataPack is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package handlers.bypasshandlers;
  20. import com.l2jserver.gameserver.handler.IBypassHandler;
  21. import com.l2jserver.gameserver.model.actor.L2Character;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.model.itemcontainer.PcFreight;
  24. import com.l2jserver.gameserver.network.SystemMessageId;
  25. import com.l2jserver.gameserver.network.serverpackets.PackageToList;
  26. import com.l2jserver.gameserver.network.serverpackets.WareHouseWithdrawalList;
  27. /**
  28. * @author UnAfraid
  29. */
  30. public class Freight implements IBypassHandler
  31. {
  32. private static final String[] COMMANDS =
  33. {
  34. "package_withdraw",
  35. "package_deposit"
  36. };
  37. @Override
  38. public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
  39. {
  40. if (!target.isNpc())
  41. {
  42. return false;
  43. }
  44. if (command.equalsIgnoreCase(COMMANDS[0]))
  45. {
  46. PcFreight freight = activeChar.getFreight();
  47. if (freight != null)
  48. {
  49. if (freight.getSize() > 0)
  50. {
  51. activeChar.setActiveWarehouse(freight);
  52. activeChar.sendPacket(new WareHouseWithdrawalList(activeChar, WareHouseWithdrawalList.FREIGHT));
  53. }
  54. else
  55. {
  56. activeChar.sendPacket(SystemMessageId.NO_ITEM_DEPOSITED_IN_WH);
  57. }
  58. }
  59. }
  60. else if (command.equalsIgnoreCase(COMMANDS[1]))
  61. {
  62. if (activeChar.getAccountChars().size() < 1)
  63. {
  64. activeChar.sendPacket(SystemMessageId.CHARACTER_DOES_NOT_EXIST);
  65. }
  66. else
  67. {
  68. activeChar.sendPacket(new PackageToList(activeChar.getAccountChars()));
  69. }
  70. }
  71. return false;
  72. }
  73. @Override
  74. public String[] getBypassList()
  75. {
  76. return COMMANDS;
  77. }
  78. }