Skip to content

Commit

Permalink
chore: replace return value of inventory with inventoryGui and add so…
Browse files Browse the repository at this point in the history
…me Contracts to enhance simple usage (#281)
  • Loading branch information
Snabeldier authored Jan 19, 2025
1 parent ce6cbc7 commit 9632a85
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/java/minevalley/core/api/gui/MultiPageGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public interface MultiPageGui extends InventoryGui {
* @throws IllegalArgumentException if the slot is out of bounds
*/
@Nullable
@Contract(pure = true)
ItemStack getItem(@Nonnegative int page, @Nonnegative int slot) throws IllegalArgumentException;

/**
Expand All @@ -35,6 +36,7 @@ public interface MultiPageGui extends InventoryGui {
* @throws IllegalArgumentException if the slot is out of bounds
*/
@Override
@Contract(pure = true)
default @Nullable ItemStack getItem(@Nonnegative int slot) throws IllegalArgumentException {
return getItem(0, slot);
}
Expand Down Expand Up @@ -103,7 +105,8 @@ MultiPageGui setPageDependantItem(@Nonnegative int slot, @Nonnull Function<Integ
* @throws IllegalArgumentException if the page is out of bounds
*/
@Nonnull
Inventory getInventory(@Nonnegative int page) throws IllegalArgumentException;
@Contract("_ -> new")
InventoryGui getInventory(@Nonnegative int page) throws IllegalArgumentException;

/**
* Opens this GUI for the specified player on the specified page.
Expand Down Expand Up @@ -135,8 +138,9 @@ MultiPageGui setPageDependantItem(@Nonnegative int slot, @Nonnull Function<Integ
* @return a copy of the underlying inventory of this GUI
*/
@Override
@Contract("-> new")
default @Nonnull Inventory getInventory() {
return getInventory(0);
return getInventory(0).getInventory();
}

/**
Expand Down

0 comments on commit 9632a85

Please sign in to comment.