From f86476bd9dd6c57181401fc0d1fe8b8e9ef5dcb4 Mon Sep 17 00:00:00 2001 From: unimatrixgit <95320811+unimatrixgit@users.noreply.github.com> Date: Mon, 30 Nov 2026 20:13:10 +0100 Subject: [PATCH 1/3] Render one selection card per House --- DuneRealmsGUI/build.gradle.kts | 2 +- .../main/java/com/dunerealms/gui/DuneGUI.java | 21 ++++++++++++++++--- DuneRealmsGUI/src/main/resources/plugin.yml | 2 +- tools/navigator-transition.json | 2 +- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/DuneRealmsGUI/build.gradle.kts b/DuneRealmsGUI/build.gradle.kts index 24a81ceb..a0e0cc32 100644 --- a/DuneRealmsGUI/build.gradle.kts +++ b/DuneRealmsGUI/build.gradle.kts @@ -1,6 +1,6 @@ plugins { java } group = "com.dunerealms" -version = "1.1.40-navigator1" +version = "1.1.41-house1" repositories { mavenCentral(); maven("https://repo.papermc.io/repository/maven-public/"); maven("https://repo.opencollab.dev/main/") } dependencies { compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT") diff --git a/DuneRealmsGUI/src/main/java/com/dunerealms/gui/DuneGUI.java b/DuneRealmsGUI/src/main/java/com/dunerealms/gui/DuneGUI.java index d77ed489..c444dd39 100644 --- a/DuneRealmsGUI/src/main/java/com/dunerealms/gui/DuneGUI.java +++ b/DuneRealmsGUI/src/main/java/com/dunerealms/gui/DuneGUI.java @@ -259,14 +259,29 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto Screen screen=screen(p,"Choose your House",0xE300+(chosen==null?0:Arrays.asList(IDS).indexOf(chosen)+1)); for(int i=0;iselect(p,data,id));} + screen.inventory.setItem(centre,item); + screen.actions.put(centre,()->select(p,data,id)); } button(screen,p,45,"Close","Return to the lobby",Material.ARROW,p::closeInventory); button(screen,p,49,sidebar.enabled(p)?"Hide scoreboard":"Show scoreboard","Toggle your personal briefing",Material.LEVER,()->{toggleSidebar(p);select(p,data,chosen);}); - for(int slot:new int[]{48,50})screen.actions.put(slot,screen.actions.get(49)); if(chosen!=null)button(screen,p,53,"Confirm "+houseName(data,chosen),"Write your confirmed House key",Material.LIME_DYE,()->confirm(p,data,chosen)); - screen.actions.put(46,screen.actions.get(45));if(chosen!=null)screen.actions.put(52,screen.actions.get(53)); if(MCGUIMenus.show(p,"Choose your House","",screen.inventory,screen.actions,screen.gate))return; + // The inventory fallback uses a multi-slot hit area for each background tile. + // Card-based menus must only receive the five center slots. + for(int i=0;iconfirm(p,data,id)),new BedrockForms.Choice("Back","Review all five Houses",()->select(p,data,id))));} diff --git a/DuneRealmsGUI/src/main/resources/plugin.yml b/DuneRealmsGUI/src/main/resources/plugin.yml index e7719ef6..e6e93948 100644 --- a/DuneRealmsGUI/src/main/resources/plugin.yml +++ b/DuneRealmsGUI/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: DunerealmsGUI main: com.dunerealms.gui.DuneGUI -version: 1.1.40-navigator1 +version: 1.1.41-house1 api-version: '1.21.8' depend: [JarvisTranslator] softdepend: [Citizens, MCGUI, DecentHolograms, DuneLobby, DuneCore, DuneEss, DuneNPC, Vault, floodgate, ViaVersion] diff --git a/tools/navigator-transition.json b/tools/navigator-transition.json index e49249cd..272608b2 100644 --- a/tools/navigator-transition.json +++ b/tools/navigator-transition.json @@ -28,7 +28,7 @@ } }, "DunerealmsGUI": { - "version": "1.1.40-navigator1", + "version": "1.1.41-house1", "changedClasses": [ "com/dunerealms/gui/DuneGUI$1.class", "com/dunerealms/gui/DuneGUI.class", -- 2.53.0 From ba79bc0b98882f11e36842810a24a9313d70cd17 Mon Sep 17 00:00:00 2001 From: unimatrixgit <95320811+unimatrixgit@users.noreply.github.com> Date: Mon, 30 Nov 2026 20:15:45 +0100 Subject: [PATCH 2/3] Cover House card handoff and fallback hit areas --- .../main/java/com/dunerealms/gui/DuneGUI.java | 27 ++++++----- .../com/dunerealms/gui/HouseCardsTest.java | 48 +++++++++++++++++++ 2 files changed, 64 insertions(+), 11 deletions(-) create mode 100644 DuneRealmsGUI/src/test/java/com/dunerealms/gui/HouseCardsTest.java diff --git a/DuneRealmsGUI/src/main/java/com/dunerealms/gui/DuneGUI.java b/DuneRealmsGUI/src/main/java/com/dunerealms/gui/DuneGUI.java index c444dd39..8a855f8a 100644 --- a/DuneRealmsGUI/src/main/java/com/dunerealms/gui/DuneGUI.java +++ b/DuneRealmsGUI/src/main/java/com/dunerealms/gui/DuneGUI.java @@ -18,6 +18,7 @@ import org.bukkit.persistence.PersistentDataType; import org.bukkit.plugin.java.JavaPlugin; import java.time.*; import java.util.*; +import java.util.function.BooleanSupplier; import java.util.function.Consumer; /** Lobby presentation only. Character authority and committed keys remain central. */ @@ -265,24 +266,28 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto button(screen,p,45,"Close","Return to the lobby",Material.ARROW,p::closeInventory); button(screen,p,49,sidebar.enabled(p)?"Hide scoreboard":"Show scoreboard","Toggle your personal briefing",Material.LEVER,()->{toggleSidebar(p);select(p,data,chosen);}); if(chosen!=null)button(screen,p,53,"Confirm "+houseName(data,chosen),"Write your confirmed House key",Material.LIME_DYE,()->confirm(p,data,chosen)); - if(MCGUIMenus.show(p,"Choose your House","",screen.inventory,screen.actions,screen.gate))return; - // The inventory fallback uses a multi-slot hit area for each background tile. - // Card-based menus must only receive the five center slots. + if(presentHouseCards(screen.inventory,screen.actions, + ()->MCGUIMenus.show(p,"Choose your House","",screen.inventory,screen.actions,screen.gate)))return; + p.openInventory(screen.inventory);expire(screen); + } + static boolean presentHouseCards(Inventory inventory,Map actions,BooleanSupplier showCards){ + if(showCards.getAsBoolean())return true; + // Only the chest fallback needs a multi-slot hit area for each background tile. for(int i=0;iconfirm(p,data,id)),new BedrockForms.Choice("Back","Review all five Houses",()->select(p,data,id))));} private void confirm(Player p,JsonObject data,String id){ diff --git a/DuneRealmsGUI/src/test/java/com/dunerealms/gui/HouseCardsTest.java b/DuneRealmsGUI/src/test/java/com/dunerealms/gui/HouseCardsTest.java new file mode 100644 index 00000000..316612be --- /dev/null +++ b/DuneRealmsGUI/src/test/java/com/dunerealms/gui/HouseCardsTest.java @@ -0,0 +1,48 @@ +package com.dunerealms.gui; + +import java.lang.reflect.Proxy; +import java.util.HashMap; +import java.util.Map; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class HouseCardsTest { + @Test void cardRendererReceivesFiveChoicesAndFallbackAloneExpandsHitAreas() { + Map items = new HashMap<>(); + Map actions = new HashMap<>(); + Inventory inventory = (Inventory) Proxy.newProxyInstance(getClass().getClassLoader(), + new Class[]{Inventory.class}, (proxy, method, args) -> switch (method.getName()) { + case "getItem" -> items.get((Integer) args[0]); + case "setItem" -> items.put((Integer) args[0], (ItemStack) args[1]); + default -> throw new UnsupportedOperationException(method.getName()); + }); + for (int centre : DuneGUI.CENTRES) { + items.put(centre, new Icon()); + actions.put(centre, () -> {}); + } + actions.put(45, () -> {}); + actions.put(49, () -> {}); + + assertTrue(DuneGUI.presentHouseCards(inventory, actions, () -> { + assertEquals(5, items.size()); + return true; + })); + assertEquals(5, items.size()); + Runnable firstHouse = actions.get(DuneGUI.CENTRES[0]); + assertFalse(DuneGUI.presentHouseCards(inventory, actions, () -> { + assertEquals(5, items.size()); + return false; + })); + assertEquals(39, items.size()); + assertSame(firstHouse, actions.get(DuneGUI.CENTRES[0] - 10)); + assertSame(actions.get(49), actions.get(48)); + assertFalse(actions.containsKey(52)); + } + + private static final class Icon extends ItemStack { + @Override public ItemStack clone() { return new Icon(); } + } +} -- 2.53.0 From c7c390972d74557347503b98aaf5400e21d0069c Mon Sep 17 00:00:00 2001 From: unimatrixgit <95320811+unimatrixgit@users.noreply.github.com> Date: Mon, 30 Nov 2026 23:24:31 +0100 Subject: [PATCH 3/3] Preserve the retained House fallback class bytes --- DuneRealmsGUI/src/main/java/com/dunerealms/gui/DuneGUI.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/DuneRealmsGUI/src/main/java/com/dunerealms/gui/DuneGUI.java b/DuneRealmsGUI/src/main/java/com/dunerealms/gui/DuneGUI.java index 8a855f8a..9bdbae99 100644 --- a/DuneRealmsGUI/src/main/java/com/dunerealms/gui/DuneGUI.java +++ b/DuneRealmsGUI/src/main/java/com/dunerealms/gui/DuneGUI.java @@ -18,7 +18,6 @@ import org.bukkit.persistence.PersistentDataType; import org.bukkit.plugin.java.JavaPlugin; import java.time.*; import java.util.*; -import java.util.function.BooleanSupplier; import java.util.function.Consumer; /** Lobby presentation only. Character authority and committed keys remain central. */ @@ -270,7 +269,7 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto ()->MCGUIMenus.show(p,"Choose your House","",screen.inventory,screen.actions,screen.gate)))return; p.openInventory(screen.inventory);expire(screen); } - static boolean presentHouseCards(Inventory inventory,Map actions,BooleanSupplier showCards){ + static boolean presentHouseCards(Inventory inventory,Map actions,java.util.function.BooleanSupplier showCards){ if(showCards.getAsBoolean())return true; // Only the chest fallback needs a multi-slot hit area for each background tile. for(int i=0;i