ClanWarehouse.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 com.l2jserver.Config;
  21. import com.l2jserver.gameserver.enums.ItemLocation;
  22. import com.l2jserver.gameserver.model.L2Clan;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.events.EventDispatcher;
  25. import com.l2jserver.gameserver.model.events.impl.character.player.clanwh.OnPlayerClanWHItemAdd;
  26. import com.l2jserver.gameserver.model.events.impl.character.player.clanwh.OnPlayerClanWHItemDestroy;
  27. import com.l2jserver.gameserver.model.events.impl.character.player.clanwh.OnPlayerClanWHItemTransfer;
  28. import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  29. public final class ClanWarehouse extends Warehouse
  30. {
  31. private final L2Clan _clan;
  32. public ClanWarehouse(L2Clan clan)
  33. {
  34. _clan = clan;
  35. }
  36. @Override
  37. public String getName()
  38. {
  39. return "ClanWarehouse";
  40. }
  41. @Override
  42. public int getOwnerId()
  43. {
  44. return _clan.getId();
  45. }
  46. @Override
  47. public L2PcInstance getOwner()
  48. {
  49. return _clan.getLeader().getPlayerInstance();
  50. }
  51. @Override
  52. public ItemLocation getBaseLocation()
  53. {
  54. return ItemLocation.CLANWH;
  55. }
  56. public String getLocationId()
  57. {
  58. return "0";
  59. }
  60. public int getLocationId(boolean dummy)
  61. {
  62. return 0;
  63. }
  64. public void setLocationId(L2PcInstance dummy)
  65. {
  66. }
  67. @Override
  68. public boolean validateCapacity(long slots)
  69. {
  70. return ((_items.size() + slots) <= Config.WAREHOUSE_SLOTS_CLAN);
  71. }
  72. @Override
  73. public L2ItemInstance addItem(String process, int itemId, long count, L2PcInstance actor, Object reference)
  74. {
  75. final L2ItemInstance item = super.addItem(process, itemId, count, actor, reference);
  76. // Notify to scripts
  77. EventDispatcher.getInstance().notifyEventAsync(new OnPlayerClanWHItemAdd(process, actor, item, this), item.getItem());
  78. return item;
  79. }
  80. @Override
  81. public L2ItemInstance addItem(String process, L2ItemInstance item, L2PcInstance actor, Object reference)
  82. {
  83. // Notify to scripts
  84. EventDispatcher.getInstance().notifyEventAsync(new OnPlayerClanWHItemAdd(process, actor, item, this), item.getItem());
  85. return super.addItem(process, item, actor, reference);
  86. }
  87. @Override
  88. public L2ItemInstance destroyItem(String process, L2ItemInstance item, long count, L2PcInstance actor, Object reference)
  89. {
  90. // Notify to scripts
  91. EventDispatcher.getInstance().notifyEventAsync(new OnPlayerClanWHItemDestroy(process, actor, item, count, this), item.getItem());
  92. return super.destroyItem(process, item, count, actor, reference);
  93. }
  94. @Override
  95. public L2ItemInstance transferItem(String process, int objectId, long count, ItemContainer target, L2PcInstance actor, Object reference)
  96. {
  97. final L2ItemInstance item = getItemByObjectId(objectId);
  98. // Notify to scripts
  99. EventDispatcher.getInstance().notifyEventAsync(new OnPlayerClanWHItemTransfer(process, actor, item, count, target), item.getItem());
  100. return super.transferItem(process, objectId, count, target, actor, reference);
  101. }
  102. }