@@ -33,6 +33,7 @@ public class InventoryAPI implements Listener {
3333 private List <ItemAPI > items ;
3434 private Consumer <InventoryAPI > function ;
3535 private Consumer <InventoryCloseEvent > closeEvent ;
36+ private Consumer <InventoryClickEvent > clickEvent ;
3637 private boolean interactionCancel ;
3738 private boolean refreshed ;
3839 private boolean build ;
@@ -166,6 +167,16 @@ public InventoryAPI setCloseFunction(final Consumer<InventoryCloseEvent> functio
166167 return this ;
167168 }
168169
170+ /**
171+ * Define the click function.
172+ * @param function A consumer, that will be triggered when the player will click in the inventory.
173+ * @return Your InventoryAPI object
174+ */
175+ public InventoryAPI setClickFunction (final Consumer <InventoryClickEvent > function ) {
176+ this .clickEvent = function ;
177+ return this ;
178+ }
179+
169180 /**
170181 * Enable interaction protection for your Inventory
171182 * @param interactionCancelled A boolean, to enable/disable
@@ -497,6 +508,8 @@ public void onInteract(final InventoryClickEvent e) {
497508 return ;
498509 if (!e .getClickedInventory ().equals (this .inventory ))
499510 return ;
511+ if (this .clickEvent != null )
512+ this .clickEvent .accept (e );
500513 e .setCancelled (this .interactionCancel );
501514 final AtomicBoolean slotRegister = new AtomicBoolean (false );
502515 this .items .forEach (itemAPI -> {
0 commit comments