Skip to content
This repository was archived by the owner on Jul 24, 2021. It is now read-only.

Commit 934d4a0

Browse files
authored
✨ An ItemAPI can now be modified (#10)
1 parent 5f1df0e commit 934d4a0

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

src/main/java/fr/bakaaless/inventory/ItemAPI.java

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
public class ItemAPI {
1414

1515
private final int slot;
16-
private final Function<Object, ItemStack> function;
16+
private Function<Object, ItemStack> function;
1717
private ItemStack item;
18-
private final boolean cancelled;
19-
private final Consumer<InventoryClickEvent> consumer;
18+
private boolean cancelled;
19+
private Consumer<InventoryClickEvent> consumer;
2020

2121
/**
2222
* @param slot The slot where will be located the item.
@@ -92,4 +92,36 @@ public boolean isCancelled() {
9292
public Consumer<InventoryClickEvent> getConsumer() {
9393
return this.consumer;
9494
}
95+
96+
/**
97+
* Change the function that create the ItemStack of the ItemAPI.
98+
* @param function the function.
99+
*/
100+
public void setFunction(final Function<Object, ItemStack> function) {
101+
this.function = function;
102+
}
103+
104+
/**
105+
* Change the item of the ItemAPI.
106+
* @param item the new item.
107+
*/
108+
public void setItem(final ItemStack item) {
109+
this.item = item;
110+
}
111+
112+
/**
113+
* Change id the interaction is cancelled.
114+
* @param cancelled is the interaction cancelled.
115+
*/
116+
public void setCancelled(final boolean cancelled) {
117+
this.cancelled = cancelled;
118+
}
119+
120+
/**
121+
* Change the consumer of the ItemAPI.
122+
* @param consumer the consumer to execute.
123+
*/
124+
public void setConsumer(final Consumer<InventoryClickEvent> consumer) {
125+
this.consumer = consumer;
126+
}
95127
}

0 commit comments

Comments
 (0)