PcRefund.java 2.4 KB

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