Cover House card handoff and fallback hit areas
Some checks failed
DuneRealms Plugin CI / plugins (push) Failing after 2m49s

This commit is contained in:
unimatrixgit 2026-11-30 20:15:45 +01:00
commit ba79bc0b98

View file

@ -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<Integer,Runnable> 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;i<CENTRES.length;i++){
int centre=CENTRES[i];
ItemStack item=screen.inventory.getItem(centre);
Runnable action=screen.actions.get(centre);
ItemStack item=inventory.getItem(centre);
Runnable action=actions.get(centre);
for(int row=i<3?-1:0;row<=1;row++)for(int col=-1;col<=1;col++){
int slot=centre+row*9+col;
if(slot==centre)continue;
screen.inventory.setItem(slot,item.clone());
screen.actions.put(slot,action);
inventory.setItem(slot,item.clone());
actions.put(slot,action);
}
}
for(int slot:new int[]{48,50})screen.actions.put(slot,screen.actions.get(49));
screen.actions.put(46,screen.actions.get(45));
if(chosen!=null)screen.actions.put(52,screen.actions.get(53));
p.openInventory(screen.inventory);expire(screen);
for(int slot:new int[]{48,50})actions.put(slot,actions.get(49));
actions.put(46,actions.get(45));
if(actions.containsKey(53))actions.put(52,actions.get(53));
return false;
}
private void confirmForm(Player p,JsonObject data,String id){BedrockForms.show(this,p,"Confirm House · "+houseName(data,id),"Confirm your allegiance to "+houseName(data,id)+". This initial selection does not grant an elected office.",List.of(new BedrockForms.Choice("Confirm House","Save through J.A.R.V.I.S.",()->confirm(p,data,id)),new BedrockForms.Choice("Back","Review all five Houses",()->select(p,data,id))));}
private void confirm(Player p,JsonObject data,String id){