From f3686fb5e48db8161e66abc2b7c67930a80eb1c4 Mon Sep 17 00:00:00 2001 From: unimatrixgit <95320811+unimatrixgit@users.noreply.github.com> Date: Sat, 28 Nov 2026 10:27:11 +0100 Subject: [PATCH] Render opt-in equipment, decision detail and war muster views --- .../fullscreen/PaperDecisionsScene.java | 71 ++++++++++++------- .../gui/DecisionsViewTransport.java | 2 +- .../java/com/dunerealms/gui/QuestMenus.java | 28 +++++--- .../java/com/dunerealms/gui/WarMenus.java | 3 +- 4 files changed, 68 insertions(+), 36 deletions(-) diff --git a/DuneFullscreenPaper/src/main/java/com/dunerealms/fullscreen/PaperDecisionsScene.java b/DuneFullscreenPaper/src/main/java/com/dunerealms/fullscreen/PaperDecisionsScene.java index 60ac0210..a3c89573 100644 --- a/DuneFullscreenPaper/src/main/java/com/dunerealms/fullscreen/PaperDecisionsScene.java +++ b/DuneFullscreenPaper/src/main/java/com/dunerealms/fullscreen/PaperDecisionsScene.java @@ -41,8 +41,8 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut private static final Font CHECKOUT_TERMS = new Font(Font.SANS_SERIF, Font.BOLD, 15); private static final Font COMPACT_CARD_TITLE = new Font(Font.SANS_SERIF, Font.BOLD, 13); private static final Font COMPACT_CARD_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 SIDEBAR_TERMS = new Font(Font.SANS_SERIF, Font.PLAIN, 11); + private static final int SIDEBAR_TERMS_WIDTH = 108, SIDEBAR_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; @@ -210,7 +210,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut private static Page page(Document document, int index) { if (document.style() == Style.EXCHANGE_CHECKOUT) return checkoutPage(document, index); - if (document.style() == Style.ITEM_ARCHIVE) return archivePage(document, index); + if (usesReadingPane(document.style())) return archivePage(document, index); var cards = document.cards(); int capacity = capacity(document.style()); if (cards.size() <= capacity) return new Page(0, document.style(), cards); @@ -225,12 +225,15 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut } private static Page archivePage(Document document, int index) { - var entries = document.cards().stream().filter(card -> !card.actionable()).toList(); - var actions = document.cards().stream().filter(Card::actionable).toList(); + var entries = document.cards().stream().filter(card -> isReadingEntry(document.style(), card)).toList(); + var actions = document.cards().stream().filter(card -> !isReadingEntry(document.style(), card)).toList(); + var entry = entries.get(index); var visible = new ArrayList(); var blank = new Card(EMPTY, "", List.of(), false); - visible.add(entries.get(index)); // The reading pane is drawn separately from the interactive tiles. + visible.add(entry); // The reading pane is drawn separately from the interactive tiles. visible.add(blank); + if (document.style() == Style.WORKSHOP) + visible.add(entry.actionable() ? new Card(entry.slot(), entry.title(), List.of(), true, entry.material()) : blank); visible.addAll(actions); while (visible.size() < STANDARD_PAGE) visible.add(blank); if (entries.size() > 1) { @@ -271,7 +274,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut scene.focus = null; for (int row = 0; row < ROWS; row++) { for (int col = 0; col < COLS; col++) { - if (!initial && (row < 3 || row > 5 || col < 4 || col > 6 || (col == 5 && capacity(scene.page.style) == STANDARD_PAGE && scene.page.style != Style.ITEM_ARCHIVE))) continue; + if (!initial && (row < 3 || row > 5 || col < 4 || col > 6 || (col == 5 && capacity(scene.page.style) == STANDARD_PAGE && !usesReadingPane(scene.page.style)))) continue; var map = new MapId(FIRST_SCENE_MAP + row * COLS + col); var image = art.getSubimage(col * 128, row * 128, 128, 128); var card = cardAt(scene.page, row, col); @@ -342,7 +345,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut private static Card cardAt(Page page, int row, int col) { if (row < 3 || row > LAST_ROW || col < 4 || col > 6) return null; - if (page.style == Style.ITEM_ARCHIVE && row == 3) return null; + if (usesReadingPane(page.style) && row == 3) return null; if (col == 5 && (capacity(page.style) == STANDARD_PAGE || row == LAST_ROW)) return null; int cap = capacity(page.style); int index = row == LAST_ROW ? cap + (col == 4 ? 0 : 1) : @@ -449,7 +452,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut int headlineWidth = draw.getFontMetrics().stringWidth(heading); draw.drawString(heading, (image.getWidth() - headlineWidth) / 2, 372); if (scene.roleplay != null) drawRoleplay(draw, scene); - else if (scene.document.style() == Style.ITEM_ARCHIVE) drawArchive(draw, scene, palette); + else if (usesReadingPane(scene.document.style())) drawArchive(draw, scene, palette); else if (scene.document.style() != Style.AUTO) drawStyledIdentity(draw, scene, palette); for (int row = 3; row <= LAST_ROW; row++) for (int col = 4; col <= 6; col++) { Card card = cardAt(scene.page, row, col); @@ -479,6 +482,9 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut private static Palette palette(Scene scene) { return switch (scene.document.style()) { + case WAR_MUSTER -> new Palette(new Color(38, 24, 28), new Color(78, 44, 53), new Color(245, 204, 177)); + case WORKSHOP -> new Palette(new Color(29, 37, 42), new Color(54, 73, 84), new Color(235, 219, 177)); + case DECISION_DETAIL -> new Palette(new Color(21, 33, 41), new Color(47, 69, 81), new Color(236, 203, 129)); 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)); @@ -504,24 +510,28 @@ 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 (document.style() == Style.GUILD || document.style() == Style.WAR_MUSTER) { + graphics.setFont(SIDEBAR_TERMS); + var terms = sidebarTerms(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; + if (usesReadingPane(document.style())) { + long navigationCount = document.cards().stream().filter(card -> !isReadingEntry(document.style(), card)).count(); + int maximumNavigation = document.style() == Style.WORKSHOP ? 1 : 2; + if (navigationCount > maximumNavigation || navigationCount == document.cards().size()) return false; + if (document.style() == Style.ITEM_ARCHIVE && navigationCount == 0) return false; } graphics.setFont(CARD_TITLE); if (document.identity() != null && !wrap(graphics, document.identity().mentat(), 112, 2).complete) return false; for (Card card : document.cards()) { boolean seal = document.style() == Style.HOUSE && nativeArt(card.material()) != null; graphics.setFont(CARD_TITLE); - if (document.style() == Style.ITEM_ARCHIVE && !card.actionable()) { + if (usesReadingPane(document.style()) && isReadingEntry(document.style(), card)) { if (!wrap(graphics, card.title(), 368, 1).complete) return false; graphics.setFont(ARCHIVE_LORE); if (!archiveLore(graphics, card).complete) return false; + if (document.style() == Style.WORKSHOP && card.actionable() && + !fitsFullCardTitle(graphics, document.style(), card)) return false; continue; } if (usesFullCardLore(document.style())) { @@ -542,7 +552,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut private static void setHeadingFont(java.awt.Graphics2D draw, Style style, String title) { int size = switch (style) { - case ITEM_ARCHIVE, GUILD, ORGANISATION -> 28; + case ITEM_ARCHIVE, GUILD, ORGANISATION, WORKSHOP, DECISION_DETAIL, WAR_MUSTER -> 28; default -> 38; }; draw.setFont(new Font(Font.SANS_SERIF, Font.BOLD, size)); @@ -555,7 +565,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut private static boolean usesFullCardLore(Style style) { return switch (style) { - case JOURNAL, CODEX, ITEM_ARCHIVE, GUILD, SPICE, ORGANISATION -> true; + case JOURNAL, CODEX, ITEM_ARCHIVE, GUILD, SPICE, ORGANISATION, WORKSHOP, DECISION_DETAIL, WAR_MUSTER -> true; default -> false; }; } @@ -571,11 +581,20 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut } private static boolean compactCardLore(Style style) { - return style == Style.SPICE || style == Style.ORGANISATION; + return style == Style.SPICE || style == Style.ORGANISATION || style == Style.WORKSHOP || style == Style.DECISION_DETAIL || style == Style.WAR_MUSTER; } - 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 boolean usesReadingPane(Style style) { + return style == Style.ITEM_ARCHIVE || style == Style.WORKSHOP; + } + + private static boolean isReadingEntry(Style style, Card card) { + if (style == Style.ITEM_ARCHIVE) return !card.actionable(); + return !card.actionable() || (!card.title().equals("Back") && !card.title().equals("Close")); + } + + private static Wrapped sidebarTerms(java.awt.Graphics2D draw, Document document) { + return wrapLore(draw, document.description().lines().toList(), SIDEBAR_TERMS_WIDTH, SIDEBAR_TERMS_LINES); } private static Wrapped archiveLore(java.awt.Graphics2D draw, Card card) { @@ -664,11 +683,11 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut draw.setColor(palette.background.darker()); draw.fillRect(644, 389, 120, 232); switch (document.style()) { - case GUILD -> { + case GUILD, WAR_MUSTER -> { draw.setColor(palette.accent); - draw.setFont(GUILD_TERMS); + draw.setFont(SIDEBAR_TERMS); int y = 406; - for (String line : guildTerms(draw, document).lines()) { + for (String line : sidebarTerms(draw, document).lines()) { draw.drawString(line, 649, y); y += draw.getFontMetrics().getHeight(); } @@ -790,6 +809,8 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut String heading = switch (title[0]) { case "NPC dashboard" -> "YOUR MISSIONS"; case "NPC next quest" -> "YOUR NEXT MISSION"; + case "NPC turn-in decision" -> "POLITICAL DECISION"; + case "NPC next quest decision" -> "DECISION RECORDED"; case "NPC turn-in" -> document.cards().stream().anyMatch(card -> card.actionable() && (card.title().equals("Claim verified reward") || card.title().equals("Next quest"))) ? "MISSION COMPLETE" : "MISSION TURN-IN"; @@ -824,7 +845,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut try { graphics.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 14)); if (!wrap(graphics, roleplay.contact, 112, 2).complete) return false; - if (!fitsCards(graphics, document, roleplay)) return false; + if (document.style() == Style.AUTO && !fitsCards(graphics, document, roleplay)) return false; graphics.setFont(CARD_LORE); String summary = roleplay.summary == null ? document.description() : String.join(" ", roleplay.summary.lore()); return wrap(graphics, summary, 112, 6).complete; diff --git a/DuneRealmsGUI/src/main/java/com/dunerealms/gui/DecisionsViewTransport.java b/DuneRealmsGUI/src/main/java/com/dunerealms/gui/DecisionsViewTransport.java index 701a6f5c..2eccaa21 100644 --- a/DuneRealmsGUI/src/main/java/com/dunerealms/gui/DecisionsViewTransport.java +++ b/DuneRealmsGUI/src/main/java/com/dunerealms/gui/DecisionsViewTransport.java @@ -19,7 +19,7 @@ public interface DecisionsViewTransport { } } - enum Style { AUTO, ORGANISATION, EXCHANGE, EXCHANGE_CHECKOUT, HOUSE, JOURNAL, CODEX, ITEM_ARCHIVE, GUILD, SPICE } + enum Style { AUTO, ORGANISATION, EXCHANGE, EXCHANGE_CHECKOUT, HOUSE, JOURNAL, CODEX, ITEM_ARCHIVE, GUILD, SPICE, WORKSHOP, DECISION_DETAIL, WAR_MUSTER } record Identity(String logo, String mentat, int portrait) {} record Document(String title, String description, List cards, Style style, Identity identity) { diff --git a/DuneRealmsGUI/src/main/java/com/dunerealms/gui/QuestMenus.java b/DuneRealmsGUI/src/main/java/com/dunerealms/gui/QuestMenus.java index b968d38a..b803d1d5 100644 --- a/DuneRealmsGUI/src/main/java/com/dunerealms/gui/QuestMenus.java +++ b/DuneRealmsGUI/src/main/java/com/dunerealms/gui/QuestMenus.java @@ -20,12 +20,12 @@ final class QuestMenus implements Listener { private final Map pending=new HashMap<>(); private final Map roleScope=new HashMap<>(); private static final class Panel implements DuneMenuInventory { - final UUID owner;final GuiSession gate;final Map actions=new HashMap<>();final List choices=new ArrayList<>();final List descriptionNotes=new ArrayList<>();final Inventory inventory;final String title;boolean journalView;String description="Your current J.A.R.V.I.S. mission journal"; + final UUID owner;final GuiSession gate;final Map actions=new HashMap<>();final List choices=new ArrayList<>();final List descriptionNotes=new ArrayList<>();final Inventory inventory;final String title;DecisionsViewTransport.Style nativeStyle;String description="Your current J.A.R.V.I.S. mission journal"; Panel(Player p,String title){owner=p.getUniqueId();gate=new GuiSession(owner);this.title=title;inventory=Bukkit.createInventory(this,54,Component.text(title,NamedTextColor.GOLD));} public Inventory getInventory(){return inventory;} } QuestMenus(JavaPlugin plugin,HouseBridge bridge,Consumer back){this.plugin=plugin;this.bridge=bridge;this.back=back;Bukkit.getPluginManager().registerEvents(this,plugin);} - void quartermaster(Player p,Runnable exchange,Runnable kits){var s=panel(p,"Gurney · Quartermaster");put(s,20,"Exchange","Buy and sell individual items",Material.EMERALD,exchange);put(s,22,"Missions & turn-ins","Collect your House T0 kit or repair its original armour.\nPrepare four parts: one iron ingot, leather, copper ingot and quartz.\nOther missions and rewards use your current central journal.",Material.WRITABLE_BOOK,()->open(p));put(s,24,"Stillsuit kits","Published clan, company and office kits",Material.NETHERITE_CHESTPLATE,kits);put(s,31,"Organisation workshop","Upgrade your held original with researched MK and rarity templates",Material.NETHERITE_UPGRADE_SMITHING_TEMPLATE,()->workshop(p,0));put(s,34,"Gurney\u0027s missions","Current bounty, campaign and ongoing duty missions",Material.BOOK,()->openRole(p,new PolQuestNpc.Role("gurney_halleck","Gurney Halleck",p.getWorld().getName(),"*",Set.of("bounty-jobs","war-service","repeatables","rd"),0)));put(s,49,"Close","Return to the world",Material.ARROW,p::closeInventory);show(p,s);} + void quartermaster(Player p,Runnable exchange,Runnable kits){var s=equipmentPanel(p,"Gurney · Quartermaster");put(s,20,"Exchange","Buy and sell individual items",Material.EMERALD,exchange);put(s,22,"Missions & turn-ins","Collect your House T0 kit or repair its original armour.\nPrepare four parts: one iron ingot, leather, copper ingot and quartz.\nOther missions and rewards use your current central journal.",Material.WRITABLE_BOOK,()->open(p));put(s,24,"Stillsuit kits","Published clan, company and office kits",Material.NETHERITE_CHESTPLATE,kits);put(s,31,"Organisation workshop","Upgrade your held original with researched MK and rarity templates",Material.NETHERITE_UPGRADE_SMITHING_TEMPLATE,()->workshop(p,0));put(s,34,"Gurney\u0027s missions","Current bounty, campaign and ongoing duty missions",Material.BOOK,()->openRole(p,new PolQuestNpc.Role("gurney_halleck","Gurney Halleck",p.getWorld().getName(),"*",Set.of("bounty-jobs","war-service","repeatables","rd"),0)));put(s,49,"Close","Return to the world",Material.ARROW,p::closeInventory);show(p,s);} private static String text(JsonObject row,String key,String fallback){return row.has(key)&&!row.get(key).isJsonNull()?row.get(key).getAsString():fallback;} private static String dialogue(JsonObject row,String field,String fallback){return row.has("dialogue")&&row.get("dialogue").isJsonObject()?text(row.getAsJsonObject("dialogue"),field,fallback):fallback;} private static boolean yes(JsonObject row,String key){return row.has(key)&&!row.get(key).isJsonNull()&&row.get(key).getAsBoolean();} @@ -33,7 +33,12 @@ final class QuestMenus implements Listener { private Panel panel(Player p,String title){var screen=new Panel(p,title);var filler=new ItemStack(Material.GRAY_STAINED_GLASS_PANE);var meta=filler.getItemMeta();meta.displayName(Component.empty());filler.setItemMeta(meta);for(int i=0;i<54;i++)screen.inventory.setItem(i,filler);return screen;} private Panel journalPanel(Player player,String title){ var screen=panel(player,title); - screen.journalView=true; + screen.nativeStyle=DecisionsViewTransport.Style.JOURNAL; + return screen; + } + private Panel equipmentPanel(Player player,String title){ + var screen=panel(player,title); + screen.nativeStyle=DecisionsViewTransport.Style.WORKSHOP; return screen; } private void put(Panel panel,int slot,String title,String description,Material material,Runnable action){ @@ -305,15 +310,17 @@ final class QuestMenus implements Listener { boolean decisions=screen.title.startsWith("NPC dashboard decision · "); boolean quests=screen.title.startsWith("NPC dashboard · ")||screen.title.startsWith("NPC turn-in · ")|| screen.title.startsWith("NPC next quest · "); - if(!decisions&&!quests&&!screen.journalView)return false; - String setting=decisions?"development.fullscreen-decisions-viewers":"development.fullscreen-quest-viewers"; + boolean detail=screen.title.startsWith("NPC turn-in decision · ")||screen.title.startsWith("NPC next quest decision · "); + if(!decisions&&!detail&&!quests&&screen.nativeStyle==null)return false; + String setting=decisions||detail?"development.fullscreen-decisions-viewers":"development.fullscreen-quest-viewers"; String dialogue=screen.description; for(int index=screen.descriptionNotes.size()-1;index>=0;index--){ String note=screen.descriptionNotes.get(index); if(dialogue.endsWith(note))dialogue=dialogue.substring(0,dialogue.length()-note.length()); } return NativeMenus.show(plugin,player,setting,screen.title,dialogue,screen.inventory,screen.actions,screen.gate, - screen.journalView?DecisionsViewTransport.Style.JOURNAL:DecisionsViewTransport.Style.AUTO,null); + detail?DecisionsViewTransport.Style.DECISION_DETAIL: + screen.nativeStyle==null?DecisionsViewTransport.Style.AUTO:screen.nativeStyle,null); } private void decisionWebsite(Player p){decisionWebsite(p,null);} private void decisionWebsite(Player p,String decision){p.closeInventory();String url="https://clans.dunerealms.com/#quests/quests?xp=pol&view=decisions";if(decision!=null&&decision.matches("[A-Z0-9-]{1,32}"))url+="&decision="+decision;p.sendMessage(Component.text("Review POL decisions on the website →",NamedTextColor.GOLD).clickEvent(ClickEvent.openUrl(url)));} @@ -368,14 +375,14 @@ final class QuestMenus implements Listener { player.sendMessage(args.length==2?"Use /missions workshop quote .":"Choose a workshop from your current authorised list."); }); } - private void workshop(Player p,int page){var input=new JsonObject();input.addProperty("action","read_refits");input.addProperty("kind","pol");request(p,input,data->{var screen=panel(p,"Organisation workshop");var owners=data.getAsJsonArray("owners");int offset=page*36;for(int i=offset;iprepareRefit(p,owner));}if(owners.isEmpty())put(screen,22,"Specialist required","Your current organisation deed must grant equipment research authority.",Material.GRAY_DYE,null);if(page>0)put(screen,45,"Previous","Earlier organisations",Material.ARROW,()->workshop(p,page-1));if(offset+36workshop(p,page+1));put(screen,49,"Back","Mission journal",Material.ARROW,()->open(p));show(p,screen);});} + private void workshop(Player p,int page){var input=new JsonObject();input.addProperty("action","read_refits");input.addProperty("kind","pol");request(p,input,data->{var screen=equipmentPanel(p,"Organisation workshop");var owners=data.getAsJsonArray("owners");int offset=page*36;for(int i=offset;iprepareRefit(p,owner));}if(owners.isEmpty())put(screen,22,"Specialist required","Your current organisation deed must grant equipment research authority.",Material.GRAY_DYE,null);if(page>0)put(screen,45,"Previous","Earlier organisations",Material.ARROW,()->workshop(p,page-1));if(offset+36workshop(p,page+1));put(screen,49,"Back","Mission journal",Material.ARROW,()->open(p));show(p,screen);});} private void prepareRefit(Player p,JsonObject owner){prepareRefit(p,owner,true);} private void prepareRefit(Player p,JsonObject owner,boolean reopen){try{var input=new JsonObject();input.addProperty("action","prepare_refit");input.addProperty("kind","pol");var selected=new JsonObject();selected.add("kind",owner.get("kind"));selected.add("id",owner.get("id"));input.add("owner",selected);input.add("snapshot",bridge.refitSnapshot(p));input.addProperty("requestId",UUID.randomUUID().toString());input.addProperty("npcUuid",bridge.starterNpc(p).toString());input.addProperty("confirmed",true);request(p,input,permit->{var plan=permit.getAsJsonObject("plan");var output=plan.getAsJsonObject("output");StringBuilder cost=new StringBuilder("Surrender the held original and:");for(var token:plan.getAsJsonObject("consume").getAsJsonArray("templates"))cost.append("\n1 ").append(token.getAsJsonObject().get("id").getAsString().replace("dr_","").replace('_',' '));if(!reopen){ refitQuotes.put(p.getUniqueId(),new RefitQuote(input.deepCopy(),p.getWorld().getUID(),System.nanoTime()+30_000_000_000L)); p.sendMessage("Refit to MK "+text(output,"equipmentMark","")+" · "+text(output,"quality","").replace('_',' ')+"."); p.sendMessage(cost.toString());p.sendMessage("Use /missions workshop apply within 30 seconds while holding the same original near Gurney."); return; - }var screen=panel(p,"Review equipment refit");Material material=Material.matchMaterial(output.get("material").getAsString());put(screen,13,"MK "+output.get("equipmentMark").getAsString()+" · "+output.get("quality").getAsString().replace('_',' '),"Original identity, name, lore and wear retained.\nExisting enchantments scale with the next tier.\nReputation level "+plan.get("requiredReputationLevel").getAsString()+" required.\n"+cost,material==null?Material.NETHERITE_UPGRADE_SMITHING_TEMPLATE:material,null);put(screen,30,"Refit original",cost+"\nOne minute between refits. Review expires after 30 seconds.",Material.LIME_DYE,()->confirmRefit(p,input));put(screen,32,"Back","Return without consuming anything",Material.ARROW,()->workshop(p,0));show(p,screen);});}catch(Exception failure){p.sendMessage(Component.text(failure.getMessage()==null?"Hold your original near Gurney’s quartermaster.":failure.getMessage(),NamedTextColor.RED));}} + }long expiresAt=System.nanoTime()+30_000_000_000L;var screen=equipmentPanel(p,"Review equipment refit");Material material=Material.matchMaterial(output.get("material").getAsString());put(screen,13,"MK "+output.get("equipmentMark").getAsString()+" · "+output.get("quality").getAsString().replace('_',' '),"Original identity, name, lore and wear retained.\nExisting enchantments scale with the next tier.\nReputation level "+plan.get("requiredReputationLevel").getAsString()+" required.\n"+cost,material==null?Material.NETHERITE_UPGRADE_SMITHING_TEMPLATE:material,null);put(screen,30,"Refit original",cost+"\nOne minute between refits. Review expires after 30 seconds.",Material.LIME_DYE,()->{if(System.nanoTime()-expiresAt>=0){p.sendMessage("The refit quote expired. Request a new one.");return;}confirmRefit(p,input);});put(screen,32,"Back","Return without consuming anything",Material.ARROW,()->workshop(p,0));show(p,screen);});}catch(Exception failure){p.sendMessage(Component.text(failure.getMessage()==null?"Hold your original near Gurney’s quartermaster.":failure.getMessage(),NamedTextColor.RED));}} private void confirmRefit(Player p,JsonObject input){ try{ if(!input.get("snapshot").equals(bridge.refitSnapshot(p))||!input.get("npcUuid").getAsString().equals(bridge.starterNpc(p).toString())){ @@ -407,7 +414,10 @@ final class QuestMenus implements Listener { put(screen,45,"Branches","Choose another branch",Material.ARROW,()->branches(p,kind,data));if(page>0)put(screen,47,"Previous","Previous missions",Material.PAPER,()->quests(p,kind,data,branch,page-1));put(screen,49,"Refresh","Read current verified quest records",Material.CLOCK,()->load(p,kind,branch,null,page));if(offset+36quests(p,kind,data,branch,page+1));show(p,screen); } private void details(Player p,String kind,JsonObject data,String branch,int page,JsonObject row){ - var role=roleScope.get(p.getUniqueId());var screen=role!=null&&kind.equals("pol")?panel(p,"NPC turn-in · "+role.name()):journalPanel(p,"Quest dossier");if(role!=null&&kind.equals("pol")){screen.description=yes(row,"canClaim")?dialogue(row,"turnIn",""):dialogue(row,"context","");roleAvatar(screen,data,role);}String title=text(row,"title","Quest"),state=text(row,"state","Pending"),description=text(row,"objective","Complete the verified objective.")+"\nProgress: "+text(row,"progress","0")+" / "+text(row,"target","0")+"\nState: "+state+"\n"+(kind.equals("pol")?"Reputation: ":"XP: ")+text(row,"xp","Not configured"); + var role=roleScope.get(p.getUniqueId());var screen=role!=null&&kind.equals("pol")?panel(p,"NPC turn-in · "+role.name()):journalPanel(p,"Quest dossier"); + if(kind.equals("personal")&&Set.of("S1-H-01","S1-H-02").contains(text(row,"id",""))) + screen.nativeStyle=DecisionsViewTransport.Style.WORKSHOP; + if(role!=null&&kind.equals("pol")){screen.description=yes(row,"canClaim")?dialogue(row,"turnIn",""):dialogue(row,"context","");roleAvatar(screen,data,role);}String title=text(row,"title","Quest"),state=text(row,"state","Pending"),description=text(row,"objective","Complete the verified objective.")+"\nProgress: "+text(row,"progress","0")+" / "+text(row,"target","0")+"\nState: "+state+"\n"+(kind.equals("pol")?"Reputation: ":"XP: ")+text(row,"xp","Not configured"); if(row.has("personalXP")&&!row.get("personalXP").isJsonNull())description+="\nBase Personal XP: "+row.get("personalXP").getAsInt();if(row.has("baseDMMinor")&&!row.get("baseDMMinor").isJsonNull())description+="\nBase funded reward: "+String.format(Locale.ROOT,"%.2f DM",row.get("baseDMMinor").getAsLong()/100.0); put(screen,13,title,description,website(row)?Material.WRITABLE_BOOK:Material.LIGHT_BLUE_DYE,null); if(website(row))put(screen,31,"Open website journal","This objective belongs to the website",Material.MAP,()->website(p)); diff --git a/DuneRealmsGUI/src/main/java/com/dunerealms/gui/WarMenus.java b/DuneRealmsGUI/src/main/java/com/dunerealms/gui/WarMenus.java index 050b4667..43fd0584 100644 --- a/DuneRealmsGUI/src/main/java/com/dunerealms/gui/WarMenus.java +++ b/DuneRealmsGUI/src/main/java/com/dunerealms/gui/WarMenus.java @@ -25,7 +25,8 @@ final class WarMenus implements Listener { private static String text(JsonObject v,String key,String fallback){return v.has(key)&&!v.get(key).isJsonNull()?v.get(key).getAsString():fallback;} private static boolean yes(JsonObject v,String key){return v.has(key)&&!v.get(key).isJsonNull()&&v.get(key).getAsBoolean();} private void put(Panel p,int slot,String title,String body,Material material,Runnable action){var item=new ItemStack(material);var meta=item.getItemMeta();meta.displayName(Component.text(title,NamedTextColor.GOLD));meta.lore(Arrays.stream(body.split("\n")).map(x->Component.text(x,NamedTextColor.GRAY)).toList());item.setItemMeta(meta);p.inventory.setItem(slot,item);if(action!=null){p.actions.put(slot,action);p.choices.add(new BedrockForms.Choice(title,body,action));}else p.description+="\n\n"+title+"\n"+body;} - private void show(Player p,Panel panel){if(BedrockForms.isBedrock(p)){BedrockForms.show(plugin,p,panel.title,panel.description,List.copyOf(panel.choices));return;}if(MCGUIMenus.show(p,panel.title,panel.title.equals("War Muster Room")?panel.baseDescription:panel.description,panel.inventory,panel.actions,panel.gate))return;p.openInventory(panel.inventory);Bukkit.getScheduler().runTaskLater(plugin,panel.gate::expire,2400L);} + private void show(Player p,Panel panel){if(BedrockForms.isBedrock(p)){BedrockForms.show(plugin,p,panel.title,panel.description,List.copyOf(panel.choices));return;}if(NativeMenus.show(plugin,p,"development.fullscreen-war-viewers",panel.title,panel.baseDescription, + panel.inventory,panel.actions,panel.gate,DecisionsViewTransport.Style.WAR_MUSTER,null))return;if(MCGUIMenus.show(p,panel.title,panel.title.equals("War Muster Room")?panel.baseDescription:panel.description,panel.inventory,panel.actions,panel.gate))return;p.openInventory(panel.inventory);Bukkit.getScheduler().runTaskLater(plugin,panel.gate::expire,2400L);} private void request(Player p,JsonObject input,Consumer result){UUID id=p.getUniqueId(),world=p.getWorld().getUID();if(!pending.add(id))return;p.closeInventory();Bukkit.getScheduler().runTaskAsynchronously(plugin,()->{JsonObject data=null;String error=null;try{data=bridge.warMuster(id,input);}catch(Exception e){error=e instanceof java.io.IOException?e.getMessage():"War muster is temporarily unavailable.";}JsonObject received=data;String message=error;if(!plugin.isEnabled())return;Bukkit.getScheduler().runTask(plugin,()->{pending.remove(id);if(!p.isOnline()||!world.equals(p.getWorld().getUID()))return;if(message!=null){p.sendMessage(message);return;}if(received==null||!yes(received,"ok")){p.sendMessage(received==null?"War muster unavailable.":text(received,"message","War muster unavailable."));return;}result.accept(received);});});} void command(Player player,String[] args){ if(args.length==0){open(player);return;}