Offer opt-in fullscreen Guild travel, spice sales and war reports

This commit is contained in:
unimatrixgit 2026-11-28 10:20:54 +01:00
commit 37dc50d850

View file

@ -184,11 +184,39 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
String quote="Guild fare: "+String.format(java.util.Locale.ROOT,"%.2f",data.getAsJsonObject("guildQuote").get("fareMinor").getAsInt()/100.0)+" DM from your central personal bank account. Collected after arrival."+(data.getAsJsonObject("guildQuote").has("subsidyMinor")?" Guild subsidy: "+String.format(java.util.Locale.ROOT,"%.2f",data.getAsJsonObject("guildQuote").get("subsidyMinor").getAsInt()/100.0)+" DM.":"");
var booked=bookings.get(p.getUniqueId());String detail=quote+"\nTravel opens at :00, :20 and :40 for five minutes."+(booked==null?"":"\nYour passage is already booked.");
if(BedrockForms.isBedrock(p)){List<BedrockForms.Choice> choices=new ArrayList<>();for(var route:GuildRoutes.ALL){boolean allowed=quotedDestinations(data.getAsJsonObject("guildQuote")).contains(route.world());choices.add(new BedrockForms.Choice((allowed?"§6":"§8")+route.name()+(allowed?(route.house().equals(house)?" · Your House":" · Imperial passage"):" · Unavailable"),allowed?detail:"Another House world",allowed?()->bookPassage(p,data,route.world()):()->travelMenu(p,data),"https://www.dunerealms.com/assets/gui/guild-world-"+route.world().replace('_','-')+(allowed?"":"-locked")+"-v1.png"));}choices.add(new BedrockForms.Choice("Cancel booking","No fare has been charged",()->{cancelBooking(p);travelMenu(p,data);}));choices.add(new BedrockForms.Choice("Your Mentat","Return to your House adviser",()->mentat(p,data)));BedrockForms.show(this,p,"Spacing Guild · Imperial passage",detail,choices);return;}
int own=Arrays.asList(IDS).indexOf(house);Screen screen=screen(p,"Spacing Guild · Imperial passage",0xE330+own);
for(int i=0;i<GuildRoutes.ALL.size();i++){var route=GuildRoutes.ALL.get(i);boolean allowed=quotedDestinations(data.getAsJsonObject("guildQuote")).contains(route.world());var item=icon(p,route.name(),allowed?detail:"Unavailable · another House world","drgui_transparent",allowed?Material.ENDER_PEARL:Material.GRAY_DYE);int centre=CENTRES[i];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());if(allowed)screen.actions.put(slot,()->bookPassage(p,data,route.world()));}}
button(screen,p,45,"Your Mentat","Return to your House adviser",Material.ARROW,()->mentat(p,data));screen.actions.put(46,screen.actions.get(45));
button(screen,p,49,"Cancel booking","No fare is taken for a cancelled booking",Material.BARRIER,()->{cancelBooking(p);travelMenu(p,data);});for(int slot:new int[]{48,50})screen.actions.put(slot,screen.actions.get(49));
if(guild!=null){button(screen,p,53,booked==null?"Book passage":"Review booked passage",detail,Material.EMERALD,()->bookPassage(p,data));screen.actions.put(52,screen.actions.get(53));}
String title="Spacing Guild · Imperial passage";
int own=Arrays.asList(IDS).indexOf(house);Screen screen=screen(p,title,0xE330+own);
var allowedDestinations=quotedDestinations(data.getAsJsonObject("guildQuote"));
var routeCards=new ArrayList<DecisionsViewTransport.Card>();
for(int i=0;i<GuildRoutes.ALL.size();i++){
var route=GuildRoutes.ALL.get(i);boolean allowed=allowedDestinations.contains(route.world());
String unavailable="Unavailable · another House world";
var item=icon(p,route.name(),allowed?detail:unavailable,"drgui_transparent",allowed?Material.ENDER_PEARL:Material.GRAY_DYE);
int centre=CENTRES[i];
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());
if(allowed)screen.actions.put(slot,()->bookPassage(p,data,route.world()));
}
routeCards.add(new DecisionsViewTransport.Card(centre,route.name(),List.of(allowed?
(route.house().equals(house)?"Your House":"Imperial passage"):unavailable),allowed,
"guild_world_"+route.world()+(allowed?"":"_locked")));
}
String cancellation="No fare is taken for a cancelled booking";
String adviser="Return to your House adviser";
button(screen,p,45,"Your Mentat",adviser,Material.ARROW,()->mentat(p,data));screen.actions.put(46,screen.actions.get(45));
routeCards.add(new DecisionsViewTransport.Card(45,"Your Mentat",List.of(adviser),true));
button(screen,p,49,"Cancel booking",cancellation,Material.BARRIER,()->{cancelBooking(p);travelMenu(p,data);});
for(int slot:new int[]{48,50})screen.actions.put(slot,screen.actions.get(49));
routeCards.add(new DecisionsViewTransport.Card(49,"Cancel booking",List.of(cancellation),true));
if(guild!=null){
String bookingLabel=booked==null?"Book passage":"Review booked passage";
button(screen,p,53,bookingLabel,detail,Material.EMERALD,()->bookPassage(p,data));screen.actions.put(52,screen.actions.get(53));
routeCards.add(new DecisionsViewTransport.Card(53,bookingLabel,List.of(),true));
}
String nativeDetail=detail;
if(booked!=null)nativeDetail+="\nBooked to "+booked.world()+" · "+String.format(Locale.ROOT,"%.2f DM",booked.fare()/100.0);
if(NativeMenus.showGuild(this,p,title,nativeDetail,routeCards,screen.actions,screen.gate))return;
if(MCGUIMenus.show(p,"Spacing Guild · Imperial passage","",screen.inventory,screen.actions,screen.gate))return;
p.openInventory(screen.inventory);expire(screen);
}