PcRefund.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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.model.itemcontainer;
  16. import java.util.logging.Level;
  17. import com.l2jserver.gameserver.datatables.ItemTable;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  20. import com.l2jserver.gameserver.model.items.instance.L2ItemInstance.ItemLocation;
  21. /**
  22. *
  23. * @author DS
  24. *
  25. */
  26. public class PcRefund extends ItemContainer
  27. {
  28. private final L2PcInstance _owner;
  29. public PcRefund(L2PcInstance owner)
  30. {
  31. _owner = owner;
  32. }
  33. @Override
  34. public String getName()
  35. {
  36. return "Refund";
  37. }
  38. @Override
  39. public L2PcInstance getOwner()
  40. {
  41. return _owner;
  42. }
  43. @Override
  44. public ItemLocation getBaseLocation()
  45. {
  46. return ItemLocation.REFUND;
  47. }
  48. @Override
  49. protected void addItem(L2ItemInstance item)
  50. {
  51. super.addItem(item);
  52. try
  53. {
  54. if (getSize() > 12)
  55. {
  56. L2ItemInstance removedItem = _items.remove(0);
  57. if (removedItem != null)
  58. {
  59. ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
  60. removedItem.updateDatabase(true);
  61. }
  62. }
  63. }
  64. catch (Exception e)
  65. {
  66. _log.log(Level.SEVERE, "addItem()", e);
  67. }
  68. }
  69. @Override
  70. public void refreshWeight()
  71. {
  72. }
  73. @Override
  74. public void deleteMe()
  75. {
  76. try
  77. {
  78. for (L2ItemInstance item : _items)
  79. {
  80. if (item != null)
  81. {
  82. ItemTable.getInstance().destroyItem("ClearRefund", item, getOwner(), null);
  83. item.updateDatabase(true);
  84. }
  85. }
  86. }
  87. catch (Exception e)
  88. {
  89. _log.log(Level.SEVERE, "deleteMe()", e);
  90. }
  91. _items.clear();
  92. }
  93. @Override
  94. public void restore()
  95. {
  96. }
  97. }