RuneHive-Game
Loading...
Searching...
No Matches
ItemContainerListener.java
Go to the documentation of this file.
1package com.runehive.game.world.items.containers;
2
3import com.runehive.game.world.items.Item;
4
5import java.util.Optional;
6
7/**
8 * A listener that is fired by {@link ItemContainer}.
9 * <p></p>
10 * One should aim to extend {@link ItemContainerAdapter} for generic use cases rather
11 * than implement this directly.
12 * @author lare96 <http://github.org/lare96>
13 */
14public interface ItemContainerListener {
15
16 /**
17 * Fired when an {@link Item} is added, removed, or replaced.
18 * @param container The {@link ItemContainer} firing the randomevent.
19 * @param oldItem The old item being removed from this container.
20 * @param newItem The new item being added to this container.
21 * @param index The index the update is occurring on.
22 * @param refresh The condition if we have to refresh this container.
23 */
24 default void itemUpdated(ItemContainer container, Optional<Item> oldItem, Optional<Item> newItem, int index, boolean refresh, boolean login) {
25 }
26
27 /**
28 * Fired when an {@link Item}s are added, removed, or replaced in bulk. This is to prevent firing multiple {@code
29 * itemUpdated(ItemContainer, int)} events for a single operation.
30 * @param container The {@link ItemContainer} firing the randomevent.
31 */
32 default void bulkItemsUpdated(ItemContainer container) {
33 }
34
35 /**
36 * Fired when the capacity of {@code container} is exceeded.
37 * @param container The {@link ItemContainer} firing the randomevent.
38 */
39 default void capacityExceeded(ItemContainer container) {
40 }
41}
An abstraction game representing a group of Items.
default void bulkItemsUpdated(ItemContainer container)
Fired when an Items are added, removed, or replaced in bulk.
default void capacityExceeded(ItemContainer container)
Fired when the capacity of container is exceeded.
default void itemUpdated(ItemContainer container, Optional< Item > oldItem, Optional< Item > newItem, int index, boolean refresh, boolean login)
Fired when an Item is added, removed, or replaced.