1package com.osroyale.game.world.items.containers.inventory;
3import com.osroyale.game.world.entity.mob.player.Player;
4import com.osroyale.game.world.items.Item;
5import com.osroyale.game.world.items.containers.ItemContainer;
6import com.osroyale.game.world.items.containers.ItemContainerAdapter;
7import com.osroyale.game.world.items.ground.GroundItem;
8import com.osroyale.net.packet.out.SendItemOnInterface;
9import com.osroyale.net.packet.out.SendItemOnInterfaceSlot;
10import com.osroyale.net.packet.out.SendMessage;
12import java.util.Arrays;
14import java.util.Optional;
15import java.util.function.Consumer;
63 public static final int SIZE = 28;
69 private final Player player;
89 public void addOrExecute(Consumer<Item> action, Optional<String> message, List<Item> items) {
91 for (Item item : items) {
95 player.inventory.add(item);
102 message.ifPresent(m -> player.send(
new SendMessage(m)));
111 public void addOrExecute(Consumer<Item> action, Optional<String> message, Item... items) {
120 public void addOrExecute(Consumer<Item> action, String message, Item... items) {
121 addOrExecute(action, Optional.of(message), Arrays.asList(items));
129 public void addOrExecute(Consumer<Item> action, String message, List<Item> items) {
156 addOrExecute(t ->
GroundItem.
create(player, t),
"@red@Some of the items were dropped since you have no room in your inventory.", items);
172 addOrExecute(t -> player.bank.depositFromNothing(t, 0),
"@red@Some of the items were banked since you have no room in your inventory.", items);
196 InventoryListener(
Player player) {
201 public void itemUpdated(
ItemContainer container, Optional<Item> oldItem, Optional<Item> newItem,
int index,
boolean refresh,
boolean login) {
203 player.send(
new SendItemOnInterfaceSlot(
getWidgetId(), newItem.orElse(
null), index));
213 return "You do not have enough space in your inventory.";
abstract String getCapacityExceededMsg()
abstract int getWidgetId()
ItemContainer(int capacity, StackPolicy policy, Item[] items)
final boolean hasCapacityFor(Item... item)
final boolean addListener(ItemContainerListener listener)
void addOrDrop(Item... items)
void addOrExecute(Consumer< Item > action, Optional< String > message, Item... items)
void addOrExecute(Consumer< Item > action, String message, Item... items)
void addOrBank(Item... items)
void refresh(Player player, int widget)
void addOrExecute(Consumer< Item > action, Optional< String > message, List< Item > items)
static final int INVENTORY_DISPLAY_ID
void addOrExecute(Consumer< Item > action, List< Item > items)
void addOrBank(List< Item > items)
void addOrExecute(Consumer< Item > action, String message, List< Item > items)
void addOrExecute(Consumer< Item > action, Item... items)
void addOrDrop(List< Item > items)
static GroundItem create(Player player, Item item)