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
6 changed files with 106 additions and 28 deletions

View file

@ -39,7 +39,10 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
private static final int FULL_CARD_LORE_LINES = 5;
private static final Font FULL_CARD_LORE = new Font(Font.SANS_SERIF, Font.PLAIN, 12);
private static final Font CHECKOUT_TERMS = new Font(Font.SANS_SERIF, Font.BOLD, 15);
private static final Font CODEX_CARD_TITLE = new Font(Font.SANS_SERIF, Font.BOLD, 13);
private static final Font COMPACT_CARD_TITLE = new Font(Font.SANS_SERIF, Font.BOLD, 13);
private static final Font SPICE_LORE = new Font(Font.SANS_SERIF, Font.PLAIN, 11);
private static final Font GUILD_TERMS = new Font(Font.SANS_SERIF, Font.PLAIN, 11);
private static final int GUILD_TERMS_WIDTH = 108, GUILD_TERMS_LINES = 16;
private static final Font ARCHIVE_LORE = new Font(Font.SANS_SERIF, Font.PLAIN, 12);
private static final int ARCHIVE_COLUMN_LINES = 7;
private static final int ARCHIVE_COLUMN_WIDTH = 177;
@ -478,6 +481,8 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
case ORGANISATION -> new Palette(new Color(16, 31, 37), new Color(29, 75, 79), new Color(142, 228, 211));
case EXCHANGE, EXCHANGE_CHECKOUT -> new Palette(new Color(42, 28, 18), new Color(91, 62, 36), new Color(245, 208, 139));
case CODEX, ITEM_ARCHIVE -> new Palette(new Color(40, 33, 24), new Color(90, 63, 37), new Color(246, 221, 158));
case GUILD -> new Palette(new Color(14, 28, 47), new Color(28, 58, 83), new Color(188, 224, 249));
case SPICE -> new Palette(new Color(54, 25, 16), new Color(105, 54, 33), new Color(255, 214, 133));
case JOURNAL -> new Palette(new Color(30, 40, 31), new Color(61, 80, 51), new Color(235, 212, 154));
case HOUSE -> new Palette(new Color(34, 26, 39), new Color(72, 52, 79), new Color(244, 211, 152));
case AUTO -> scene.roleplay == null
@ -498,6 +503,11 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
var terms = checkoutTerms(graphics, document.description());
if (terms.isEmpty() || terms.size() > 9) return false;
}
if (document.style() == Style.GUILD) {
graphics.setFont(GUILD_TERMS);
var terms = guildTerms(graphics, document);
if (terms.lines().isEmpty() || !terms.complete()) return false;
}
if (document.style() == Style.ITEM_ARCHIVE) {
long actionCount = document.cards().stream().filter(Card::actionable).count();
if (actionCount < 1 || actionCount > 2 || actionCount == document.cards().size()) return false;
@ -515,8 +525,8 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
}
if (usesFullCardLore(document.style())) {
if (!fitsFullCardTitle(graphics, document.style(), card)) return false;
graphics.setFont(FULL_CARD_LORE);
if (!fullCardLore(graphics, card).complete) return false;
graphics.setFont(document.style() == Style.SPICE ? SPICE_LORE : FULL_CARD_LORE);
if (!fullCardLore(graphics, document.style(), card).complete) return false;
continue;
}
if (!wrap(graphics, card.title(), 114, seal ? 2 : 3).complete) return false;
@ -530,17 +540,28 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
}
private static Font styledHeadingFont(Style style) {
return new Font(Font.SANS_SERIF, Font.BOLD, style == Style.ITEM_ARCHIVE ? 30 : 38);
return new Font(Font.SANS_SERIF, Font.BOLD, style == Style.ITEM_ARCHIVE || style == Style.GUILD ? 28 : 38);
}
private static boolean usesFullCardLore(Style style) {
return style == Style.JOURNAL || style == Style.CODEX || style == Style.ITEM_ARCHIVE;
return switch (style) {
case JOURNAL, CODEX, ITEM_ARCHIVE, GUILD, SPICE -> true;
default -> false;
};
}
private static boolean fitsFullCardTitle(java.awt.Graphics2D draw, Style style, Card card) {
boolean codex = style == Style.CODEX;
draw.setFont(codex ? CODEX_CARD_TITLE : CARD_TITLE);
return wrap(draw, card.title(), 114, codex ? 3 : 2).complete();
boolean compact = compactCardTitle(style);
draw.setFont(compact ? COMPACT_CARD_TITLE : CARD_TITLE);
return wrap(draw, card.title(), 114, compact ? 3 : 2).complete();
}
private static boolean compactCardTitle(Style style) {
return style == Style.CODEX || style == Style.GUILD || style == Style.SPICE;
}
private static Wrapped guildTerms(java.awt.Graphics2D draw, Document document) {
return wrapLore(draw, document.description().lines().toList(), GUILD_TERMS_WIDTH, GUILD_TERMS_LINES);
}
private static Wrapped archiveLore(java.awt.Graphics2D draw, Card card) {
@ -584,8 +605,8 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
return lines;
}
private static Wrapped fullCardLore(java.awt.Graphics2D draw, Card card) {
return wrapLore(draw, card.lore(), 114, FULL_CARD_LORE_LINES);
private static Wrapped fullCardLore(java.awt.Graphics2D draw, Style style, Card card) {
return wrapLore(draw, card.lore(), 114, style == Style.SPICE ? 6 : FULL_CARD_LORE_LINES);
}
private static Wrapped wrapLore(java.awt.Graphics2D draw, List<String> entries, int width, int limit) {
@ -629,6 +650,16 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
draw.setColor(palette.background.darker());
draw.fillRect(644, 389, 120, 232);
switch (document.style()) {
case GUILD -> {
draw.setColor(palette.accent);
draw.setFont(GUILD_TERMS);
int y = 406;
for (String line : guildTerms(draw, document).lines()) {
draw.drawString(line, 649, y);
y += draw.getFontMetrics().getHeight();
}
}
case SPICE -> drawSceneArt(draw, "npc_world_arrakis", 650, 422, 108, 162);
case JOURNAL, CODEX -> {
drawResource(draw, "/mcgui/dunerealms-season-logo-v2.png", 650, 449, 108, 96);
draw.setColor(palette.accent);
@ -669,16 +700,19 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
if (usesFullCardLore(style)) {
draw.drawLine(x + 7, y + 48, x + 121, y + 48);
draw.setColor(Color.WHITE);
boolean codex = style == Style.CODEX;
draw.setFont(codex ? CODEX_CARD_TITLE : CARD_TITLE);
writeWrapped(draw, card.title(), x + 7, y + (codex ? 15 : 21), 114, codex ? 3 : 2);
boolean compact = compactCardTitle(style);
draw.setFont(compact ? COMPACT_CARD_TITLE : CARD_TITLE);
writeWrapped(draw, card.title(), x + 7, y + (compact ? 15 : 21), 114, compact ? 3 : 2);
draw.setColor(palette.accent);
draw.setFont(FULL_CARD_LORE);
int lineY = y + 64;
for (String line : fullCardLore(draw, card).lines()) {
draw.setFont(style == Style.SPICE ? SPICE_LORE : FULL_CARD_LORE);
int lineY = y + (style == Style.SPICE ? 55 : 64);
for (String line : fullCardLore(draw, style, card).lines()) {
draw.drawString(line, x + 7, lineY);
lineY += draw.getFontMetrics().getHeight();
}
if (style == Style.GUILD && card.actionable() && card.material().startsWith("guild_world_")) {
drawSceneArt(draw, "npc_world_" + card.material().substring("guild_world_".length()), x + 70, y + 76, 51, 42);
}
return true;
} else if (style == Style.ORGANISATION) {
draw.fillRect(x, y + 3, 4, 122);

View file

@ -19,7 +19,7 @@ public interface DecisionsViewTransport {
}
}
enum Style { AUTO, ORGANISATION, EXCHANGE, EXCHANGE_CHECKOUT, HOUSE, JOURNAL, CODEX, ITEM_ARCHIVE }
enum Style { AUTO, ORGANISATION, EXCHANGE, EXCHANGE_CHECKOUT, HOUSE, JOURNAL, CODEX, ITEM_ARCHIVE, GUILD, SPICE }
record Identity(String logo, String mentat, int portrait) {}
record Document(String title, String description, List<Card> cards, Style style, Identity identity) {

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);
}

View file

@ -2,6 +2,7 @@ package com.dunerealms.gui;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
@ -19,6 +20,20 @@ final class NativeMenus {
if (transport == null) return false;
var cards = MCGUIMenus.cards(inventory, actions).stream().map(card ->
new DecisionsViewTransport.Card(card.slot(), card.title(), card.lore(), card.action(), card.material())).toList();
return show(player, plugin, transport, title, description, cards, actions, gate, style, branding);
}
static boolean showGuild(JavaPlugin plugin, Player player, String title, String description,
List<DecisionsViewTransport.Card> cards, Map<Integer,Runnable> actions, GuiSession gate) {
if (!plugin.getConfig().getStringList("development.fullscreen-guild-viewers").contains(player.getUniqueId().toString())) return false;
var transport = Bukkit.getServicesManager().load(DecisionsViewTransport.class);
return transport != null && show(player, plugin, transport, title, description, cards, actions, gate,
DecisionsViewTransport.Style.GUILD, null);
}
private static boolean show(Player player, JavaPlugin plugin, DecisionsViewTransport transport, String title,
String description, List<DecisionsViewTransport.Card> cards, Map<Integer,Runnable> actions,
GuiSession gate, DecisionsViewTransport.Style style, MenuDocument.Branding branding) {
var identity = branding == null ? null :
new DecisionsViewTransport.Identity(branding.logo(), branding.mentat(), branding.portrait());
var document = new DecisionsViewTransport.Document(title, description, cards, style, identity);

View file

@ -22,12 +22,12 @@ final class OrganisationMenus implements Listener {
private static final class Panel implements DuneMenuInventory {
final UUID owner;final GuiSession gate;final Map<Integer,Runnable> actions=new HashMap<>();final Map<Integer,BedrockForms.Choice> choices=new TreeMap<>();String title;DecisionsViewTransport.Style nativeStyle;boolean artwork;Inventory inventory;MenuDocument.Branding branding;
final UUID owner;final GuiSession gate;final Map<Integer,Runnable> actions=new HashMap<>();final Map<Integer,BedrockForms.Choice> choices=new TreeMap<>();String title;String nativeSetting;DecisionsViewTransport.Style nativeStyle;boolean artwork;Inventory inventory;MenuDocument.Branding branding;
Panel(Player p){owner=p.getUniqueId();gate=new GuiSession(owner);}
public Inventory getInventory(){return inventory;}
}
OrganisationMenus(JavaPlugin plugin,HouseBridge bridge,Consumer<Player> mentat,Consumer<Player> travel,Consumer<Player> house,Consumer<Player> quests,Consumer<Player> decisions,Consumer<Player> exchange,Consumer<Player> spice,java.util.function.Predicate<Player> artwork){this.plugin=plugin;this.bridge=bridge;this.mentat=mentat;this.travel=travel;this.house=house;this.quests=quests;this.decisions=decisions;this.exchange=exchange;this.spice=spice;this.artwork=artwork;Bukkit.getPluginManager().registerEvents(this,plugin);}
void console(Player p){var panel=panel(p,"Imperial Codex",0);panel.nativeStyle=DecisionsViewTransport.Style.CODEX;put(panel,8,"Emergency rescue · 1,000 DM","Teleport to safety and heal · 24-hour cooldown",Material.TOTEM_OF_UNDYING,()->p.performCommand("duneess:rescue"));if(p.getWorld().getName().equals("arrakis"))put(panel,28,"Spice buyers","Spacing Guild · Smuggler · P&O payout",Material.ORANGE_DYE,()->spice.accept(p));put(panel,34,"Exchange","Buy, sell and collect your purchases",Material.CHEST,()->exchange.accept(p));var exchangeIcon=new ItemStack(Material.CHEST);var exchangeMeta=exchangeIcon.getItemMeta();exchangeMeta.displayName(Component.text("Exchange",NamedTextColor.GOLD));exchangeMeta.lore(List.of(Component.text("Buy · Sell · Add held item",NamedTextColor.GRAY)));exchangeIcon.setItemMeta(exchangeMeta);panel.inventory.setItem(34,exchangeIcon);put(panel,31,"Mission journal","Personal Experience and Reputation",Material.WRITABLE_BOOK,()->quests.accept(p));put(panel,32,"Decisions","Your current J.A.R.V.I.S. decisions",Material.ENCHANTED_BOOK,()->decisions.accept(p));put(panel,4,"Item lore archive","Preview the shared item lore cards",Material.WRITABLE_BOOK,()->lore(p));put(panel,19,"Clan","Your clan and Home Block",Material.GREEN_BANNER,()->open(p,"clans"));put(panel,22,"Company","Your companies and Home Blocks",Material.CYAN_BANNER,()->open(p,"companies"));put(panel,25,"POL","Your current political offices",Material.PURPLE_BANNER,()->open(p,"offices"));put(panel,37,"Your Mentat","Your personal briefing",Material.BOOK,()->mentat.accept(p));put(panel,40,"Spacing Guild","Transport and boarding windows",Material.COMPASS,()->travel.accept(p));put(panel,43,"Your House","Your allegiance and adviser",Material.NETHER_STAR,()->house.accept(p));close(panel,p);show(p,panel);}
void console(Player p){var panel=panel(p,"Imperial Codex",0);panel.nativeStyle=DecisionsViewTransport.Style.CODEX;panel.nativeSetting="development.fullscreen-codex-viewers";put(panel,8,"Emergency rescue · 1,000 DM","Teleport to safety and heal · 24-hour cooldown",Material.TOTEM_OF_UNDYING,()->p.performCommand("duneess:rescue"));if(p.getWorld().getName().equals("arrakis"))put(panel,28,"Spice buyers","Spacing Guild · Smuggler · P&O payout",Material.ORANGE_DYE,()->spice.accept(p));put(panel,34,"Exchange","Buy, sell and collect your purchases",Material.CHEST,()->exchange.accept(p));var exchangeIcon=new ItemStack(Material.CHEST);var exchangeMeta=exchangeIcon.getItemMeta();exchangeMeta.displayName(Component.text("Exchange",NamedTextColor.GOLD));exchangeMeta.lore(List.of(Component.text("Buy · Sell · Add held item",NamedTextColor.GRAY)));exchangeIcon.setItemMeta(exchangeMeta);panel.inventory.setItem(34,exchangeIcon);put(panel,31,"Mission journal","Personal Experience and Reputation",Material.WRITABLE_BOOK,()->quests.accept(p));put(panel,32,"Decisions","Your current J.A.R.V.I.S. decisions",Material.ENCHANTED_BOOK,()->decisions.accept(p));put(panel,4,"Item lore archive","Preview the shared item lore cards",Material.WRITABLE_BOOK,()->lore(p));put(panel,19,"Clan","Your clan and Home Block",Material.GREEN_BANNER,()->open(p,"clans"));put(panel,22,"Company","Your companies and Home Blocks",Material.CYAN_BANNER,()->open(p,"companies"));put(panel,25,"POL","Your current political offices",Material.PURPLE_BANNER,()->open(p,"offices"));put(panel,37,"Your Mentat","Your personal briefing",Material.BOOK,()->mentat.accept(p));put(panel,40,"Spacing Guild","Transport and boarding windows",Material.COMPASS,()->travel.accept(p));put(panel,43,"Your House","Your allegiance and adviser",Material.NETHER_STAR,()->house.accept(p));close(panel,p);show(p,panel);}
void open(Player p,String kind){
if(!busy.add(p.getUniqueId()))return;
Bukkit.getScheduler().runTaskAsynchronously(plugin,()->{JsonObject data=null;try{data=bridge.organisations(p.getUniqueId());}catch(Exception ignored){}JsonObject result=data;if(!plugin.isEnabled())return;
@ -96,7 +96,7 @@ final class OrganisationMenus implements Listener {
});
}
void lore(Player p){
var panel=panel(p,"Item lore archive · Preview",false);panel.nativeStyle=DecisionsViewTransport.Style.ITEM_ARCHIVE;String[] kinds={"MENU","EQUIPMENT","KIT","COMPONENT","TICKET","CASH","RIHLA","DEED","QUEST"};Material[] materials={Material.COMPASS,Material.IRON_SWORD,Material.CHEST,Material.AMETHYST_SHARD,Material.PAPER,Material.GOLD_NUGGET,Material.WRITABLE_BOOK,Material.MAP,Material.BOOK};
var panel=panel(p,"Item lore archive · Preview",false);panel.nativeStyle=DecisionsViewTransport.Style.ITEM_ARCHIVE;panel.nativeSetting="development.fullscreen-codex-viewers";String[] kinds={"MENU","EQUIPMENT","KIT","COMPONENT","TICKET","CASH","RIHLA","DEED","QUEST"};Material[] materials={Material.COMPASS,Material.IRON_SWORD,Material.CHEST,Material.AMETHYST_SHARD,Material.PAPER,Material.GOLD_NUGGET,Material.WRITABLE_BOOK,Material.MAP,Material.BOOK};
for(int i=0;i<kinds.length;i++){String kind=kinds[i];Map<String,String> facts=switch(kind){case "EQUIPMENT"->Map.of("Grade","From issued equipment key","House","From House key","Durability","From actual item");case "KIT"->Map.of("Contents","From kit definition","State","Design preview");case "COMPONENT"->Map.of("Recipe","From crafting definition");case "TICKET"->Map.of("Route","From passage key","Departure",":00 / :20 / :40");case "CASH"->Map.of("Value","From bank withdrawal","State","Design preview");case "RIHLA"->Map.of("Recipient","From RIA key","Amount","From transfer record");case "DEED"->Map.of("Organisation","From registered deed","Holder","From current authority");case "QUEST"->Map.of("Objective","From mission key","Progress","From verified events");default->Map.of("Service","DuneRealms","Access","Current JARVIS keys");};try{panel.inventory.setItem(18+i,bridge.lorePreview(kind,materials[i],kind.replace('_',' '),facts));}catch(Exception unavailable){p.sendMessage("The lore renderer is temporarily unavailable.");return;}}
put(panel,45,"Back","Imperial Codex",Material.ARROW,()->console(p));close(panel,p);show(p,panel);
}
@ -183,7 +183,7 @@ final class OrganisationMenus implements Listener {
});
}
private void warStatus(Player p,Runnable back){
var screen=panel(p,"War report",false);JsonObject result;
var screen=panel(p,"War report",false);screen.nativeStyle=DecisionsViewTransport.Style.JOURNAL;screen.nativeSetting="development.fullscreen-organisation-viewers";JsonObject result;
try{result=bridge.warReport(p.getUniqueId());}catch(Exception unavailable){p.sendMessage("War reports are temporarily unavailable.");return;}
var campaigns=result.getAsJsonArray("campaigns");
if(campaigns==null||campaigns.isEmpty())put(screen,22,"No active deployment","No current roster lease.\nArrange wars through your Clan or POL control panel.",Material.MAP,()->warStatus(p,back));
@ -223,7 +223,7 @@ final class OrganisationMenus implements Listener {
private Panel panel(Player p,String title,int screen){if(!artwork.test(p)||BedrockForms.isBedrock(p))return panel(p,title,screen==2);var panel=new Panel(p);panel.title=title;panel.artwork=true;panel.inventory=Bukkit.createInventory(panel,54,Component.text(GuiArtwork.background(0xE340+screen),NamedTextColor.WHITE).font(net.kyori.adventure.key.Key.key("dunerealms:house_selector")));return panel;}
private void put(Panel panel,int slot,String title,String description,Material material,Runnable action){var item=new ItemStack(panel.artwork?Material.PAPER:material);var meta=item.getItemMeta();meta.displayName(Component.text(title,NamedTextColor.GOLD));meta.lore(Arrays.stream(description.split("\n")).map(line->Component.text(line,NamedTextColor.GRAY)).toList());if(panel.artwork)meta.setItemModel(new NamespacedKey("dunerealms","drgui_transparent"));item.setItemMeta(meta);panel.inventory.setItem(slot,item);panel.actions.put(slot,action);if(panel.artwork&&Set.of(19,22,25,37,40,43).contains(slot))for(int alias:new int[]{slot-1,slot+1}){panel.inventory.setItem(alias,item.clone());panel.actions.put(alias,action);}panel.choices.put(slot,new BedrockForms.Choice(title,description,action));}
private void close(Panel panel,Player p){put(panel,53,"Close","Return to the game",Material.BARRIER,p::closeInventory);}
private void show(Player p,Panel panel){brandingRequests.remove(p.getUniqueId());if(BedrockForms.isBedrock(p)){BedrockForms.show(plugin,p,panel.title,panel.branding==null||panel.branding.mentat().isEmpty()?"Current organisation keys":"Mentat · "+panel.branding.mentat(),List.copyOf(panel.choices.values()));return;}if(panel.nativeStyle!=null&&NativeMenus.show(plugin,p,"development.fullscreen-codex-viewers",panel.title,"",panel.inventory,panel.actions,panel.gate,panel.nativeStyle,null))return;if(panel.branding!=null&&NativeMenus.show(plugin,p,"development.fullscreen-organisation-viewers",panel.title,"",panel.inventory,panel.actions,panel.gate,DecisionsViewTransport.Style.ORGANISATION,panel.branding))return;if(MCGUIMenus.show(p,panel.title,"Current organisation keys",panel.inventory,panel.actions,panel.gate,panel.branding))return;p.openInventory(panel.inventory);Bukkit.getScheduler().runTaskLater(plugin,panel.gate::expire,2400L);}
private void show(Player p,Panel panel){brandingRequests.remove(p.getUniqueId());if(BedrockForms.isBedrock(p)){BedrockForms.show(plugin,p,panel.title,panel.branding==null||panel.branding.mentat().isEmpty()?"Current organisation keys":"Mentat · "+panel.branding.mentat(),List.copyOf(panel.choices.values()));return;}if(panel.nativeStyle!=null&&NativeMenus.show(plugin,p,panel.nativeSetting,panel.title,"",panel.inventory,panel.actions,panel.gate,panel.nativeStyle,null))return;if(panel.branding!=null&&NativeMenus.show(plugin,p,"development.fullscreen-organisation-viewers",panel.title,"",panel.inventory,panel.actions,panel.gate,DecisionsViewTransport.Style.ORGANISATION,panel.branding))return;if(MCGUIMenus.show(p,panel.title,"Current organisation keys",panel.inventory,panel.actions,panel.gate,panel.branding))return;p.openInventory(panel.inventory);Bukkit.getScheduler().runTaskLater(plugin,panel.gate::expire,2400L);}
@EventHandler public void click(InventoryClickEvent e){if(!(e.getView().getTopInventory().getHolder() instanceof Panel panel))return;e.setCancelled(true);if(!(e.getWhoClicked() instanceof Player p)||!panel.owner.equals(p.getUniqueId())||e.getClickedInventory()!=panel.inventory||e.getClick()!=ClickType.LEFT)return;var action=panel.actions.get(e.getRawSlot());if(action!=null&&panel.gate.claim(p.getUniqueId()))Bukkit.getScheduler().runTask(plugin,()->{if(p.isOnline()&&p.getOpenInventory().getTopInventory()==panel.inventory)action.run();});}
@EventHandler public void drag(InventoryDragEvent e){if(e.getView().getTopInventory().getHolder() instanceof Panel)e.setCancelled(true);}
@EventHandler public void closed(InventoryCloseEvent e){if(e.getInventory().getHolder() instanceof Panel panel)panel.gate.expire();}

View file

@ -65,7 +65,8 @@ final class SpiceMenus implements Listener {
private void recover(Player p){if(!arrakis(p))return;call(p,action("pending"),data->recoverNext(p,data.getAsJsonArray("pending").asList().stream().map(v->UUID.fromString(v.getAsString())).toList(),0));}
private void recoverNext(Player p,List<UUID> ids,int index){if(!arrakis(p))return;if(index>=ids.size()){p.sendMessage(ids.isEmpty()?"No spice payments are waiting.":"Pending spice payments processed.");return;}var q=action("settle");q.addProperty("requestId",ids.get(index).toString());call(p,q,data->recoverNext(p,ids,index+1));}
private static void put(Panel panel,int slot,Material material,String name,String lore,Runnable action,String art){var item=new ItemStack(material);var meta=item.getItemMeta();meta.displayName(Component.text(name,NamedTextColor.GOLD));meta.lore(Arrays.stream(lore.split("\n")).map(line->Component.text(line,NamedTextColor.GRAY)).toList());if(art!=null)meta.getPersistentDataContainer().set(new NamespacedKey("dunerealms","menu_art"),org.bukkit.persistence.PersistentDataType.STRING,art);item.setItemMeta(meta);panel.inventory.setItem(slot,item);if(action!=null)panel.actions.put(slot,action);}
private void show(Player p,Panel panel){if(BedrockForms.isBedrock(p)){var choices=panel.actions.entrySet().stream().map(entry->new BedrockForms.Choice(net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer.plainText().serialize(panel.inventory.getItem(entry.getKey()).getItemMeta().displayName()),"",entry.getValue())).toList();BedrockForms.show(plugin,p,"Arrakis · Spice buyer","P&O pays your personal bank account",choices);return;}if(!MCGUIMenus.show(p,"Arrakis · Spice buyer","Guild trade and quest-authorised smuggling",panel.inventory,panel.actions,panel.gate))p.openInventory(panel.inventory);}
private void show(Player p,Panel panel){if(BedrockForms.isBedrock(p)){var choices=panel.actions.entrySet().stream().map(entry->new BedrockForms.Choice(net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer.plainText().serialize(panel.inventory.getItem(entry.getKey()).getItemMeta().displayName()),"",entry.getValue())).toList();BedrockForms.show(plugin,p,"Arrakis · Spice buyer","P&O pays your personal bank account",choices);return;}if(NativeMenus.show(plugin,p,"development.fullscreen-spice-viewers","Arrakis · Spice buyer","",
panel.inventory,panel.actions,panel.gate,DecisionsViewTransport.Style.SPICE,null))return;if(!MCGUIMenus.show(p,"Arrakis · Spice buyer","Guild trade and quest-authorised smuggling",panel.inventory,panel.actions,panel.gate))p.openInventory(panel.inventory);}
@EventHandler public void click(InventoryClickEvent e){if(!(e.getView().getTopInventory().getHolder() instanceof Panel panel))return;e.setCancelled(true);if(!panel.owner.equals(e.getWhoClicked().getUniqueId()))return;Runnable action=panel.actions.get(e.getRawSlot());if(action!=null&&panel.gate.claim(e.getWhoClicked().getUniqueId()))Bukkit.getScheduler().runTask(plugin,action);}
@EventHandler public void drag(InventoryDragEvent e){if(e.getView().getTopInventory().getHolder() instanceof Panel)e.setCancelled(true);}
}