From cb966222c1838b232ad14d2c1805c6c4f5125f8b Mon Sep 17 00:00:00 2001 From: Hugo Torres Date: Tue, 11 Mar 2025 18:14:06 +0100 Subject: [PATCH 1/2] Add configuration option to hide pagination buttons for single page --- src/main/resources/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 1163216..07e4ba1 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -64,6 +64,9 @@ max-vault-amount: -1 # if enabled, the icon picker will not close after selecting an item selector-stay-open: false +# should we hide pagination buttons if there is only 1 page? +hide-pagination: true + # list of items that CAN'T be put in vaults # note: the name-contains string shouldn't include any color codes blacklisted-items: From d44dc03025760315cde3e85bd8774dd590ffa291 Mon Sep 17 00:00:00 2001 From: Hugo Torres Date: Tue, 11 Mar 2025 18:14:17 +0100 Subject: [PATCH 2/2] Add option to hide pagination buttons when only one page is available --- .../axvaults/guis/VaultSelector.java | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/artillexstudios/axvaults/guis/VaultSelector.java b/src/main/java/com/artillexstudios/axvaults/guis/VaultSelector.java index 8fb82ef..a0c25fd 100644 --- a/src/main/java/com/artillexstudios/axvaults/guis/VaultSelector.java +++ b/src/main/java/com/artillexstudios/axvaults/guis/VaultSelector.java @@ -50,27 +50,31 @@ public void open(@NotNull Player player, int page) { }); } - final Section prev; - if ((prev = MESSAGES.getSection("gui-items.previous-page")) != null) { - final GuiItem item1 = new GuiItem(new ItemBuilder(prev).get()); - item1.setAction(event -> gui.previous()); - gui.setItem(rows, 3, item1); - } + boolean hidePagination = CONFIG.getBoolean("hide-pagination", false) && gui.getPagesNum() <= 1; + + if (!hidePagination) { + final Section prev; + if ((prev = MESSAGES.getSection("gui-items.previous-page")) != null) { + final GuiItem item1 = new GuiItem(new ItemBuilder(prev).get()); + item1.setAction(event -> gui.previous()); + gui.setItem(rows, 3, item1); + } - final Section next; - if ((next = MESSAGES.getSection("gui-items.next-page")) != null) { - final GuiItem item2 = new GuiItem(new ItemBuilder(next).get()); - item2.setAction(event -> { - gui.next(); - - for (int i = 0; i < pageSize; i++) { - getItemOfVault(player, (gui.getCurrentPageNum() * pageSize) + i + 1, gui, guiItem -> { - if (guiItem == null) return; - gui.addItem(guiItem); - }); - } - }); - gui.setItem(rows, 7, item2); + final Section next; + if ((next = MESSAGES.getSection("gui-items.next-page")) != null) { + final GuiItem item2 = new GuiItem(new ItemBuilder(next).get()); + item2.setAction(event -> { + gui.next(); + + for (int i = 0; i < pageSize; i++) { + getItemOfVault(player, (gui.getCurrentPageNum() * pageSize) + i + 1, gui, guiItem -> { + if (guiItem == null) return; + gui.addItem(guiItem); + }); + } + }); + gui.setItem(rows, 7, item2); + } } final Section close; @@ -83,6 +87,7 @@ public void open(@NotNull Player player, int page) { gui.open(player, page); } + private void getItemOfVault(@NotNull Player player, int num, @NotNull PaginatedGui gui, Consumer consumer) { int maxVaults = CONFIG.getInt("max-vault-amount"); if (maxVaults != -1 && num > maxVaults) {