forked from unimatrix/web
Declare House allegiance directly from the menu or command
This commit is contained in:
parent
0a11a18274
commit
419251ebda
2 changed files with 22 additions and 11 deletions
|
|
@ -102,6 +102,11 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
|
|||
if(sender instanceof Player player&&command.getName().equals("drgui")&&args.length==1&&args[0].equalsIgnoreCase("item")){giveCodex(player,true);return true;}
|
||||
if(sender instanceof Player member&&List.of("clan","company","polgui").contains(command.getName())){organisations.open(member,command.getName().equals("clan")?"clans":command.getName().equals("company")?"companies":"offices");return true;}
|
||||
if(!(sender instanceof Player p))return true;
|
||||
if(command.getName().equals("house")&&args.length>0){
|
||||
String id=args[0].toLowerCase(Locale.ROOT);
|
||||
if(args.length!=1||!HOUSE_IDS.contains(id)){p.sendMessage("Use /house <"+String.join("|",IDS)+">");return true;}
|
||||
fetch(p,null,0,null,data->declareHouse(p,data,id,false));return true;
|
||||
}
|
||||
if(command.getName().equals("rosterkey")){if(args.length!=1)p.sendMessage("Use /rosterkey <team invite code>");else warMenus.accept(p,args[0]);return true;}
|
||||
if(command.getName().equals("warmuster")){warMenus.open(p);return true;}
|
||||
if(command.getName().equals("start")){quests.starterJournal(p);return true;}
|
||||
|
|
@ -219,28 +224,33 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
|
|||
if(BedrockForms.isBedrock(p)){
|
||||
List<BedrockForms.Choice> choices=new ArrayList<>();
|
||||
for(var entry:data.getAsJsonArray("choices")){var house=entry.getAsJsonObject();String id=house.get("id").getAsString();if(!HOUSE_IDS.contains(id))continue;
|
||||
choices.add(new BedrockForms.Choice(house.get("name").getAsString()+(id.equals(current)?" · Your House":""),"Review and confirm allegiance",()->confirmForm(p,data,id),"https://www.dunerealms.com/assets/seals/"+house.get("seal").getAsString()));
|
||||
choices.add(new BedrockForms.Choice(house.get("name").getAsString()+(id.equals(current)?" · Your House":""),"Declare allegiance to this House",()->declareHouse(p,data,id,true),"https://www.dunerealms.com/assets/seals/"+house.get("seal").getAsString()));
|
||||
}
|
||||
choices.add(new BedrockForms.Choice(sidebar.enabled(p)?"Hide scoreboard":"Show scoreboard","Personal briefing display",()->{toggleSidebar(p);select(p,data,picked);}));
|
||||
BedrockForms.show(this,p,"Choose your House","Declare your allegiance. Review a House before confirming.",choices);return;
|
||||
BedrockForms.show(this,p,"Choose your House","Choose a House to declare your allegiance.",choices);return;
|
||||
}
|
||||
Screen screen=screen(p,"Choose your House",0xE300+(chosen==null?0:Arrays.asList(IDS).indexOf(chosen)+1));
|
||||
for(int i=0;i<IDS.length;i++){String id=IDS[i];int centre=CENTRES[i];boolean selected=id.equals(chosen);
|
||||
var item=icon(p,houseName(data,id),selected?"Selected · confirm below":"Click to select this House","drgui_transparent",Material.PAPER);menuArt(item,"house_"+id);
|
||||
for(int row=i<3?-1:0;row<=1;row++)for(int col=-1;col<=1;col++){int slot=centre+row*9+col;screen.inventory.setItem(slot,item.clone());screen.actions.put(slot,()->select(p,data,id));}
|
||||
var item=icon(p,houseName(data,id),selected?"Your current House":"Declare allegiance to this House","drgui_transparent",Material.PAPER);menuArt(item,"house_"+id);
|
||||
for(int row=i<3?-1:0;row<=1;row++)for(int col=-1;col<=1;col++){int slot=centre+row*9+col;screen.inventory.setItem(slot,item.clone());screen.actions.put(slot,()->declareHouse(p,data,id,true));}
|
||||
}
|
||||
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));
|
||||
screen.actions.put(46,screen.actions.get(45));
|
||||
if(MCGUIMenus.show(p,"Choose your House","",screen.inventory,screen.actions,screen.gate))return;
|
||||
p.openInventory(screen.inventory);expire(screen);
|
||||
}
|
||||
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){
|
||||
if(id.equals(selection(data))&&data.has("keyId")&&!data.get("keyId").isJsonNull()){mentat(p,data);return;}
|
||||
fetch(p,id,data.get("version").getAsInt(),UUID.randomUUID(),saved->{p.sendMessage(Component.text("House allegiance confirmed in J.A.R.V.I.S.",NamedTextColor.GREEN));mentat(p,saved);});
|
||||
private void declareHouse(Player p,JsonObject data,String id,boolean openMenu){
|
||||
if(id.equals(selection(data))&&data.has("keyId")&&!data.get("keyId").isJsonNull()){
|
||||
if(openMenu)mentat(p,data);
|
||||
else p.sendMessage("Your House is "+houseName(data,id)+".");
|
||||
return;
|
||||
}
|
||||
fetch(p,id,data.get("version").getAsInt(),UUID.randomUUID(),saved->{
|
||||
p.sendMessage(Component.text("House allegiance saved in J.A.R.V.I.S.",NamedTextColor.GREEN));
|
||||
if(openMenu)mentat(p,saved);
|
||||
});
|
||||
}
|
||||
private void mentat(Player p,JsonObject data){
|
||||
String house=selection(data);if(house==null){select(p,data,null);return;}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ commands:
|
|||
drscoreboard:
|
||||
description: Toggle your private Personal XP, Reputation, bank and organisation scoreboard
|
||||
house:
|
||||
description: Open the five-House allegiance selector
|
||||
description: View Houses or declare your allegiance
|
||||
usage: /house [house]
|
||||
aliases: [houses]
|
||||
mentat:
|
||||
description: Open your current House adviser
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff