PcRefund.java 2.3 KB

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