From f3e6fe29b039437cb364ce1f61c5c9d824ccfd08 Mon Sep 17 00:00:00 2001 From: unimatrixgit <95320811+unimatrixgit@users.noreply.github.com> Date: Sat, 28 Nov 2026 10:10:34 +0100 Subject: [PATCH] Render the player mission journal in the opt-in fullscreen viewer --- .../fullscreen/PaperDecisionsScene.java | 40 ++++++++++++++++++- .../gui/DecisionsViewTransport.java | 2 +- .../java/com/dunerealms/gui/QuestMenus.java | 23 ++++++----- 3 files changed, 54 insertions(+), 11 deletions(-) diff --git a/DuneFullscreenPaper/src/main/java/com/dunerealms/fullscreen/PaperDecisionsScene.java b/DuneFullscreenPaper/src/main/java/com/dunerealms/fullscreen/PaperDecisionsScene.java index 23e4bef1..a72ec70f 100644 --- a/DuneFullscreenPaper/src/main/java/com/dunerealms/fullscreen/PaperDecisionsScene.java +++ b/DuneFullscreenPaper/src/main/java/com/dunerealms/fullscreen/PaperDecisionsScene.java @@ -36,6 +36,8 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut private static final int LAST_ROW = 5, LAST_CARD_HEIGHT = 64; private static final Font CARD_TITLE = new Font(Font.SANS_SERIF, Font.BOLD, 17); private static final Font CARD_LORE = new Font(Font.SANS_SERIF, Font.PLAIN, 13); + private static final int JOURNAL_LORE_LINES = 5; + private static final Font JOURNAL_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 int PREVIOUS = -1, NEXT = -2, EMPTY = -3; private static final int CHECKOUT_BACK = 45, CHECKOUT_BUY = 49, CHECKOUT_CONTROLS = 2; @@ -451,6 +453,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut return switch (scene.document.style()) { 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 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 ? new Palette(new Color(25, 40, 46), new Color(52, 93, 107), new Color(237, 199, 105)) @@ -475,6 +478,12 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut for (Card card : document.cards()) { boolean seal = document.style() == Style.HOUSE && nativeArt(card.material()) != null; graphics.setFont(CARD_TITLE); + if (document.style() == Style.JOURNAL) { + if (!wrap(graphics, card.title(), 114, 2).complete) return false; + graphics.setFont(JOURNAL_LORE); + if (!journalLore(graphics, card).complete) return false; + continue; + } if (!wrap(graphics, card.title(), 114, seal ? 2 : 3).complete) return false; graphics.setFont(CARD_LORE); if (!wrap(graphics, styledLore(document.style(), card), 114, seal ? 2 : 3).complete) return false; @@ -503,6 +512,16 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut return lines; } + private static Wrapped journalLore(java.awt.Graphics2D draw, Card card) { + var lines = new ArrayList(); + for (String entry : card.lore()) { + var wrapped = wrap(draw, entry, 114, JOURNAL_LORE_LINES - lines.size()); + lines.addAll(wrapped.lines()); + if (!wrapped.complete()) return new Wrapped(lines, false); + } + return new Wrapped(lines, true); + } + private static String styledLore(Style style, Card card) { if (card.lore().isEmpty()) return ""; if (style == Style.HOUSE && card.material().startsWith("house_")) @@ -534,6 +553,12 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut draw.setColor(palette.background.darker()); draw.fillRect(644, 389, 120, 232); switch (document.style()) { + case JOURNAL -> { + drawResource(draw, "/mcgui/dunerealms-season-logo-v2.png", 650, 449, 108, 96); + draw.setColor(palette.accent); + draw.drawLine(650, 446, 758, 446); + draw.drawLine(650, 549, 758, 549); + } case EXCHANGE_CHECKOUT -> { draw.setColor(Color.WHITE); draw.setFont(CHECKOUT_TERMS); @@ -565,7 +590,20 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut if (style == Style.AUTO) return false; String art = nativeArt(card.material()); draw.setColor(palette.accent); - if (style == Style.ORGANISATION) { + if (style == Style.JOURNAL) { + draw.drawLine(x + 7, y + 48, x + 121, y + 48); + draw.setColor(Color.WHITE); + draw.setFont(CARD_TITLE); + writeWrapped(draw, card.title(), x + 7, y + 21, 114, 2); + draw.setColor(palette.accent); + draw.setFont(JOURNAL_LORE); + int lineY = y + 64; + for (String line : journalLore(draw, card).lines()) { + draw.drawString(line, x + 7, lineY); + lineY += draw.getFontMetrics().getHeight(); + } + return true; + } else if (style == Style.ORGANISATION) { draw.fillRect(x, y + 3, 4, 122); draw.drawLine(x + 7, y + 69, x + 119, y + 69); } else if (style == Style.EXCHANGE || style == Style.EXCHANGE_CHECKOUT) { diff --git a/DuneRealmsGUI/src/main/java/com/dunerealms/gui/DecisionsViewTransport.java b/DuneRealmsGUI/src/main/java/com/dunerealms/gui/DecisionsViewTransport.java index fe2f1bf1..9d717da7 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 } + enum Style { AUTO, ORGANISATION, EXCHANGE, EXCHANGE_CHECKOUT, HOUSE, JOURNAL } 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 4b956443..b968d38a 100644 --- a/DuneRealmsGUI/src/main/java/com/dunerealms/gui/QuestMenus.java +++ b/DuneRealmsGUI/src/main/java/com/dunerealms/gui/QuestMenus.java @@ -20,7 +20,7 @@ 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;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;boolean journalView;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;} } @@ -31,12 +31,17 @@ final class QuestMenus implements Listener { private static boolean yes(JsonObject row,String key){return row.has(key)&&!row.get(key).isJsonNull()&&row.get(key).getAsBoolean();} private static boolean website(JsonObject row){return row.has("executionRequirements")&&!row.get("executionRequirements").isJsonNull()&&yes(row.getAsJsonObject("executionRequirements"),"website")&&!yes(row.getAsJsonObject("executionRequirements"),"minecraft");} 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; + return screen; + } private void put(Panel panel,int slot,String title,String description,Material material,Runnable action){ var item=new ItemStack(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());item.setItemMeta(meta);panel.inventory.setItem(slot,item); if(action==null){String note="\n\n"+title+"\n"+description;panel.description+=note;panel.descriptionNotes.add(note);} if(action!=null){panel.actions.put(slot,action);panel.choices.add(new BedrockForms.Choice(title,description,action));} } - private void show(Player p,Panel screen){if(BedrockForms.isBedrock(p)){BedrockForms.show(plugin,p,screen.title,screen.description,List.copyOf(screen.choices));return;}if(showDevelopmentRoleplay(p,screen))return;if(MCGUIMenus.show(p,screen.title,screen.description,screen.inventory,screen.actions,screen.gate))return;p.openInventory(screen.inventory);Bukkit.getScheduler().runTaskLater(plugin,screen.gate::expire,2400L);} + private void show(Player p,Panel screen){if(BedrockForms.isBedrock(p)){BedrockForms.show(plugin,p,screen.title,screen.description,List.copyOf(screen.choices));return;}if(showDevelopmentView(p,screen))return;if(MCGUIMenus.show(p,screen.title,screen.description,screen.inventory,screen.actions,screen.gate))return;p.openInventory(screen.inventory);Bukkit.getScheduler().runTaskLater(plugin,screen.gate::expire,2400L);} void close(){pending.clear();for(Player p:Bukkit.getOnlinePlayers())if(p.getOpenInventory().getTopInventory().getHolder() instanceof Panel)p.closeInventory();} private record RefitQuote(JsonObject input,UUID world,long expires){} private final Map refitQuotes=new HashMap<>(); @@ -179,7 +184,7 @@ final class QuestMenus implements Listener { } player.sendMessage("That NPC step is unavailable for this mission."); } - void open(Player p){roleScope.remove(p.getUniqueId());var screen=panel(p,"Mission journal");put(screen,20,"Personal Experience","Your personal mission branches",Material.BOOK,()->load(p,"personal",null,null,0));put(screen,24,"Reputation","Your Reputation mission branches",Material.ENCHANTED_BOOK,()->load(p,"pol",null,null,0));put(screen,31,"Political decisions","Decisions available to your current offices",Material.WRITABLE_BOOK,()->openDecisions(p,0));put(screen,45,"Website Mentat Report","Open your full online journal",Material.MAP,()->website(p));put(screen,49,"Back","Imperial Codex",Material.ARROW,()->back.accept(p));show(p,screen);} + void open(Player p){roleScope.remove(p.getUniqueId());var screen=journalPanel(p,"Mission journal");put(screen,20,"Personal Experience","Your personal mission branches",Material.BOOK,()->load(p,"personal",null,null,0));put(screen,24,"Reputation","Your Reputation mission branches",Material.ENCHANTED_BOOK,()->load(p,"pol",null,null,0));put(screen,31,"Political decisions","Decisions available to your current offices",Material.WRITABLE_BOOK,()->openDecisions(p,0));put(screen,45,"Website Mentat Report","Open your full online journal",Material.MAP,()->website(p));put(screen,49,"Back","Imperial Codex",Material.ARROW,()->back.accept(p));show(p,screen);} void starterJournal(Player p){roleScope.remove(p.getUniqueId());load(p,"personal","h",null,0);} void openRole(Player p,PolQuestNpc.Role role){roleScope.put(p.getUniqueId(),role);if(role.branches().contains("prologue")){housePrologue(p,role);return;}load(p,"pol",null,null,0);} private void housePrologue(Player p,PolQuestNpc.Role role){var input=new JsonObject();input.addProperty("action","read");input.addProperty("kind","personal");input.addProperty("npcRole",role.key());request(p,input,data->{var screen=panel(p,"NPC turn-in · "+role.name());roleAvatar(screen,data,role);var state=data.has("housePrologue")&&data.get("housePrologue").isJsonObject()?data.getAsJsonObject("housePrologue"):new JsonObject();screen.description=text(state,"dialogue","");if(!yes(state,"required")){put(screen,13,"Welcome back","Your established preparation is retained. Use the existing Guild Navigator for passage.",Material.COMPASS,null);}else if(!role.key().equals(text(state,"mentor",""))){put(screen,13,"Choose your House","Meet the adviser of your current House. Visit the existing account and House selection flow.",Material.BOOK,null);put(screen,31,"Open account and House selection","Complete your account and select a House before returning.",Material.MAP,()->{p.closeInventory();p.sendMessage(Component.text("Open your account and House selection →",NamedTextColor.GOLD).clickEvent(ClickEvent.openUrl("https://cp.dunerealms.com/")));});}else{put(screen,13,"House Prologue","Account setup: "+(yes(state,"onboarding")?"Verified":"Pending")+"\nProfile: "+(yes(state,"profile")?"Verified":"Pending")+"\nMentat introduction: "+(yes(state,"introduced")?"Verified":"Pending")+"\nStarter equipment: "+(yes(state,"kit")?"Verified":"Pending"),Material.WRITABLE_BOOK,null);if(!yes(state,"introduced"))put(screen,31,"Acknowledge House introduction","Record this matching Mentat interaction. Rewards are issued automatically on verification.",Material.LIME_DYE,()->{try{bridge.houseMentorIntroduction(p,role.key());p.sendMessage("Introduction recorded. Reopen this contact to refresh your verified progress.");}catch(Exception error){p.sendMessage("Return to your matching House Mentat.");}});else if(!yes(state,"kit"))put(screen,31,"Your starter equipment","Open the existing starter objective; retain your original shovel and kit.",Material.WOODEN_SHOVEL,()->{p.closeInventory();p.performCommand("start");});else if(yes(state,"ready"))put(screen,31,"Your first passage is unlocked","Use the existing Guild Navigator to travel to your native world.",Material.COMPASS,null);else put(screen,31,"Finish account preparation","Complete the existing website profile and first sign-in requirements.",Material.MAP,()->{p.closeInventory();p.sendMessage(Component.text("Open your account →",NamedTextColor.GOLD).clickEvent(ClickEvent.openUrl("https://cp.dunerealms.com/")));});}put(screen,49,"Refresh","Check your actual progress and automatically recorded rewards",Material.ARROW,()->housePrologue(p,role));show(p,screen);});} @@ -296,11 +301,11 @@ final class QuestMenus implements Listener { show(p,screen); },true); } - private boolean showDevelopmentRoleplay(Player player,Panel screen){ + private boolean showDevelopmentView(Player player,Panel screen){ 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)return false; + if(!decisions&&!quests&&!screen.journalView)return false; String setting=decisions?"development.fullscreen-decisions-viewers":"development.fullscreen-quest-viewers"; String dialogue=screen.description; for(int index=screen.descriptionNotes.size()-1;index>=0;index--){ @@ -308,7 +313,7 @@ final class QuestMenus implements Listener { 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, - DecisionsViewTransport.Style.AUTO,null); + screen.journalView?DecisionsViewTransport.Style.JOURNAL:DecisionsViewTransport.Style.AUTO,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)));} @@ -390,19 +395,19 @@ final class QuestMenus implements Listener { } private void load(Player p,String kind,String branch,String selected,int page){var input=new JsonObject();input.addProperty("action","read");input.addProperty("kind",kind);var contact=roleScope.get(p.getUniqueId());if(contact!=null&&kind.equals("pol"))input.addProperty("npcRole",contact.key());request(p,input,data->{if(!"active".equals(text(data,"state",""))){p.sendMessage("No active quest season is available.");open(p);return;}var role=roleScope.get(p.getUniqueId());if(role!=null&&kind.equals("pol")){roleJournal(p,data,role,selected);return;}if(branch==null)branches(p,kind,data);else if(selected==null)quests(p,kind,data,branch,page);else{JsonObject row=null;for(var entry:data.getAsJsonArray("quests"))if(selected.equals(text(entry.getAsJsonObject(),"id","")))row=entry.getAsJsonObject();if(row==null)quests(p,kind,data,branch,page);else details(p,kind,data,branch,page,row);}});} private void branches(Player p,String kind,JsonObject data){ - var screen=panel(p,kind.equals("pol")?"Reputation branches":"Personal mission branches");var branches=new LinkedHashMap();for(var entry:data.getAsJsonArray("quests")){String id=text(entry.getAsJsonObject(),"branch","missions");branches.putIfAbsent(id,id);} + var screen=journalPanel(p,kind.equals("pol")?"Reputation branches":"Personal mission branches");var branches=new LinkedHashMap();for(var entry:data.getAsJsonArray("quests")){String id=text(entry.getAsJsonObject(),"branch","missions");branches.putIfAbsent(id,id);} if(data.has("branches"))for(var entry:data.getAsJsonArray("branches")){var branch=entry.getAsJsonObject();String id=text(branch,"id","");if(branches.containsKey(id))branches.put(id,text(branch,"title",id));} int slot=0;for(var branch:branches.entrySet()){if(slot>=45)break;String id=branch.getKey();put(screen,slot++,branch.getValue(),"Open this mission branch",Material.WRITABLE_BOOK,()->quests(p,kind,data,id,0));}put(screen,49,"Back","Mission journal",Material.ARROW,()->open(p));show(p,screen); } private void quests(Player p,String kind,JsonObject data,String branch,int page){ var rows=new ArrayList();for(var entry:data.getAsJsonArray("quests")){var row=entry.getAsJsonObject();if(branch.equals(text(row,"branch","")))rows.add(row);} - int offset=page*36;var screen=panel(p,"Missions · "+branch);for(int i=offset;idetails(p,kind,data,branch,page,row));} + int offset=page*36;var screen=journalPanel(p,"Missions · "+branch);for(int i=offset;idetails(p,kind,data,branch,page,row));} if(kind.equals("personal")&&branch.equals("e")){put(screen,36,"Official Spice Harvesting","Reputation careers · genuine harvested spice",Material.ORANGE_DYE,()->load(p,"pol","spice-harvesting",null,0));put(screen,38,"Smuggling Jobs","Native roaming smuggler contracts",Material.CHEST,()->load(p,"pol","smugglers",null,0));put(screen,40,"Bounty Jobs","Accept and complete an actual bounty",Material.MAP,()->load(p,"pol","bounty-jobs",null,0));} if(kind.equals("pol")&&branch.equals("bounty-jobs"))put(screen,40,"View active bounties","Open /dune bounty on Arrakis",Material.PAPER,()->{p.closeInventory();p.performCommand("dune bounty");}); 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=panel(p,role!=null&&kind.equals("pol")?"NPC turn-in · "+role.name():"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(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));