@@ -47,6 +47,23 @@ public ItemAPI(final int slot, final Function<Object, ItemStack> function, final
4747 this .consumer = consumer ;
4848 }
4949
50+ /**
51+ * @param slot The slot where will be located the item.
52+ * @param item The wished ItemStack
53+ * @param function A function that return an ItemStack, for the refresh task
54+ * @param cancelled The boolean to enable/disable the interaction protection for this slot
55+ * @param consumer A lambda expression that correspond to the executed code when item is clicked
56+ */
57+ private ItemAPI (final int slot , final ItemStack item , final Function <Object , ItemStack > function , final boolean cancelled , final Consumer <InventoryClickEvent > consumer ) {
58+ this .slot = slot ;
59+ this .item = item ;
60+ this .function = function ;
61+ this .item = new ItemStack (Material .AIR );
62+ this .refresh (this );
63+ this .cancelled = cancelled ;
64+ this .consumer = consumer ;
65+ }
66+
5067 /**
5168 * Refresh this item at its slot.
5269 * @param o An {@link InventoryAPI} instance.
@@ -124,4 +141,19 @@ public void setCancelled(final boolean cancelled) {
124141 public void setConsumer (final Consumer <InventoryClickEvent > consumer ) {
125142 this .consumer = consumer ;
126143 }
144+
145+ public ItemAPI clone () {
146+ return new ItemAPI (this .slot , this .item , this .function , this .cancelled , this .consumer );
147+ }
148+
149+ @ Override
150+ public String toString () {
151+ return "ItemAPI{" +
152+ "slot=" + this .slot +
153+ ", function=" + this .function +
154+ ", item=" + this .item +
155+ ", cancelled=" + this .cancelled +
156+ ", consumer=" + this .consumer +
157+ '}' ;
158+ }
127159}
0 commit comments