Skip to content

Commit

Permalink
add interface item methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Snabeldier committed Jan 16, 2025
1 parent c2b11e7 commit df6ae87
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/main/java/minevalley/core/api/gui/InventoryGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@ public interface InventoryGui {
@Contract("_, _ -> this")
InventoryGui setItem(@Nonnegative int slot, @Nonnull ItemStack item) throws IllegalArgumentException;

/**
* Sets the interface item in the specified slot.
*
* @param slot the slot to set the item in
* @param item the interface item to set
* @return this GUI
* @throws IllegalArgumentException if the slot is out of bounds, or the interface item is null
*/
@Nonnull
@Contract("_, _ -> this")
default InventoryGui setItem(@Nonnegative int slot, @Nonnull InterfaceItem item) throws IllegalArgumentException {
return setItem(slot, item.toItemStack());
}

/**
* Sets the item in the specified slot.
*
Expand All @@ -52,6 +66,21 @@ public interface InventoryGui {
@Contract("_, _, _ -> this")
InventoryGui setItem(@Nonnegative int slot, @Nonnull ItemStack item, @Nonnull Consumer<OnlineUser> onClick) throws IllegalArgumentException;

/**
* Sets the interface item in the specified slot.
*
* @param slot the slot to set the interface item in
* @param item the item to set
* @param onClick the consumer to run when the item is clicked
* @return this GUI
* @throws IllegalArgumentException if the slot is out of bounds, or the interface item or onClick is null
*/
@Nonnull
@Contract("_, _, _ -> this")
default InventoryGui setItem(@Nonnegative int slot, @Nonnull InterfaceItem item, @Nonnull Consumer<OnlineUser> onClick) throws IllegalArgumentException {
return setItem(slot, item.toItemStack(), onClick);
}

/**
* Sets the item in the specified slot.
*
Expand All @@ -65,6 +94,21 @@ public interface InventoryGui {
@Contract("_, _, _ -> this")
InventoryGui setItem(@Nonnegative int slot, @Nonnull ItemStack item, @Nonnull BiConsumer<OnlineUser, InventoryClickEvent> onClick) throws IllegalArgumentException;

/**
* Sets the interface item in the specified slot.
*
* @param slot the slot to set the interface item in
* @param item the item to set
* @param onClick the consumer to run when the item is clicked
* @return this GUI
* @throws IllegalArgumentException if the slot is out of bounds, or the interface item or onClick is null
*/
@Nonnull
@Contract("_, _, _ -> this")
default InventoryGui setItem(@Nonnegative int slot, @Nonnull InterfaceItem item, @Nonnull BiConsumer<OnlineUser, InventoryClickEvent> onClick) throws IllegalArgumentException {
return setItem(slot, item.toItemStack(), onClick);
}

/**
* Placed the specified interface item in the specified slots.
*
Expand Down

0 comments on commit df6ae87

Please sign in to comment.