diff --git a/bukkit/src/main/java/net/william278/husksync/player/BukkitPlayer.java b/bukkit/src/main/java/net/william278/husksync/player/BukkitPlayer.java index 1ef48112..f8789cba 100644 --- a/bukkit/src/main/java/net/william278/husksync/player/BukkitPlayer.java +++ b/bukkit/src/main/java/net/william278/husksync/player/BukkitPlayer.java @@ -568,7 +568,7 @@ public class BukkitPlayer extends OnlineUser { @Override public CompletableFuture> showMenu(@NotNull ItemData itemData, boolean editable, - int rows, @NotNull MineDown title) { + int minimumRows, @NotNull MineDown title) { final CompletableFuture> updatedData = new CompletableFuture<>(); // Deserialize the item data to be shown and show it in a triumph GUI @@ -576,7 +576,10 @@ public class BukkitPlayer extends OnlineUser { try { // Build the GUI and populate with items final int itemCount = items.length; - final StorageBuilder guiBuilder = Gui.storage().title(title.toComponent()).rows(rows).disableAllInteractions(); + final StorageBuilder guiBuilder = Gui.storage() + .title(title.toComponent()) + .rows(Math.max(minimumRows, (int) Math.ceil(itemCount / 9.0))) + .disableAllInteractions(); final StorageGui gui = editable ? guiBuilder.enableAllInteractions().create() : guiBuilder.create(); for (int i = 0; i < itemCount; i++) { if (items[i] != null) { diff --git a/common/src/main/java/net/william278/husksync/player/OnlineUser.java b/common/src/main/java/net/william278/husksync/player/OnlineUser.java index 452b1a5d..6ad067e5 100644 --- a/common/src/main/java/net/william278/husksync/player/OnlineUser.java +++ b/common/src/main/java/net/william278/husksync/player/OnlineUser.java @@ -206,8 +206,18 @@ public abstract class OnlineUser extends User { */ public abstract boolean hasPermission(@NotNull String node); + /** + * Show a GUI chest menu to the player, containing the given {@link ItemData} + * + * @param itemData Item data to be shown in the GUI + * @param editable If the player should be able to remove, replace and move around the items + * @param minimumRows The minimum number of rows to show in the chest menu + * @param title The title of the chest menu, as a {@link MineDown} locale + * @return A future returning the {@link ItemData} in the chest menu when the player closes it + * @since 2.1 + */ public abstract CompletableFuture> showMenu(@NotNull ItemData itemData, boolean editable, - int rows, @NotNull MineDown title); + int minimumRows, @NotNull MineDown title); /** * Returns true if the player is dead diff --git a/common/src/test/java/net/william278/husksync/player/DummyPlayer.java b/common/src/test/java/net/william278/husksync/player/DummyPlayer.java index 94a13cfd..aa52b8d5 100644 --- a/common/src/test/java/net/william278/husksync/player/DummyPlayer.java +++ b/common/src/test/java/net/william278/husksync/player/DummyPlayer.java @@ -149,7 +149,7 @@ public class DummyPlayer extends OnlineUser { @Override public CompletableFuture> showMenu(@NotNull ItemData itemData, boolean editable, - int rows, @NotNull MineDown title) { + int minimumRows, @NotNull MineDown title) { // do nothing return CompletableFuture.completedFuture(Optional.empty()); }