PcRefund.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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.L2ItemInstance;
  19. import com.l2jserver.gameserver.model.L2ItemInstance.ItemLocation;
  20. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  21. /**
  22. *
  23. * @author DS
  24. *
  25. */
  26. public class PcRefund extends ItemContainer
  27. {
  28. private 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;
  57. synchronized (_items)
  58. {
  59. removedItem = _items.remove(0);
  60. }
  61. if (removedItem != null)
  62. {
  63. ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
  64. removedItem.updateDatabase(true);
  65. }
  66. }
  67. }
  68. catch (Exception e)
  69. {
  70. _log.log(Level.SEVERE, "addItem()", e);
  71. }
  72. }
  73. @Override
  74. public void refreshWeight()
  75. {
  76. }
  77. @Override
  78. public void deleteMe()
  79. {
  80. try
  81. {
  82. for (L2ItemInstance item : _items)
  83. {
  84. if (item != null)
  85. {
  86. ItemTable.getInstance().destroyItem("ClearRefund", item, getOwner(), null);
  87. item.updateDatabase(true);
  88. }
  89. }
  90. }
  91. catch (Exception e)
  92. {
  93. _log.log(Level.SEVERE, "deleteMe()", e);
  94. }
  95. _items.clear();
  96. }
  97. @Override
  98. public void restore()
  99. {
  100. }
  101. }