PcRefund.java 2.3 KB

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