Polish menu cards and route Exchange commands through working native service

This commit is contained in:
unimatrixgit 2026-11-29 11:17:13 +01:00
commit 628f3af943
13 changed files with 132 additions and 14 deletions

View file

@ -1,7 +1,7 @@
import java.security.MessageDigest
plugins { java }
group = "com.dunerealms"
version = "2.0.1"
version = "2.0.2"
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
@ -49,3 +49,9 @@ tasks.register<JavaExec>("verifyMenuRenderer") {
jvmArgs("-Djava.awt.headless=true")
args(providers.gradleProperty("rendererOutput").getOrElse(layout.buildDirectory.dir("renderer-verification").get().asFile.absolutePath))
}
// Reuse committed central artwork. No network requests occur when a menu opens.
tasks.processResources {
from("../network/resource-pack/vanilla-art/overlay") { into("menu-art/pack") }
from("../network/resource-pack/central/overlay") { into("menu-art/pack"); include("assets/dunerealms/items/**", "assets/dunerealms/models/**", "assets/dunerealms/textures/**") }
}

View file

@ -0,0 +1,20 @@
# Menu polish and Exchange command parity
Objective: preserve the accepted fast full-screen menu design while containing text, improving artwork and making the public Exchange command use the already working native Exchange flow.
## Scope
- DuneMenus 2.0.2: bounded compact summaries and titles; full original long lore remains below the grid, without adding a confirmation action. Private-use inventory glyphs and legacy formatting codes are removed from display text. House-adviser wording avoids assigning every adviser the Mentat profession. Council actions use a balanced grid; the Your House arrow is an ordinary action rather than a paging control.
- Local illustrated website logo, proportionally contained in the header. Canonical PNG SHA256 267fe0d0b5adb4f2fb657d1d6827d030e7f837c94335d0a3643210b908f47931. Menu item icons resolve the actual ItemStack item_model to an existing central-pack flat texture. No quality/mark is inferred from a name. Unsupported dynamic/complex models retain a semantic fallback; this is not a general 3D item renderer.
- Artwork is packaged from committed central inputs and unpacked at plugin startup. Model/image lookups are cached. There are no remote artwork requests on menu opening.
- GUI 1.1.36 routes /exchange, namespaced aliases and /drgui exchange to the existing native ExchangeMenus.open path before the supplied-command interceptor. That is the same service used by the working GUI button and remains displayed by the fast ServiceMenu renderer.
No economy, bank, purchase reference, retry, payment, delivery, JARVIS, Core, Ess, quest or raider implementation changes. Existing native purchase selection and settlement behaviour remains unchanged. This change does not clear an uncertain earlier purchase or replay a transaction.
## Verification and release
Local DuneMenus and GUI tests pass. Pinned real MCGUI 0.8.6 renderer checks fifteen menu families and 152 original action hitboxes; text-bound checks include long titles/descriptions and full scroll pages. A separate actual-image fixture renders the central legendary axe texture with the illustrated logo and cleaned lore. These are offline fixtures, not real purchase or connected-client acceptance.
Canonical exact-head CI, manifest review and guarded frontend-only canary are still required. Select only DuneMenus and DunerealmsGUI incoming JARs; retain all working backend binaries and current resource-pack pin. Verify actual command/GUI parity and representative custom item icons in-game, without speculative payment tests.
Client-side coordinate/minimap overlays are outside this layout. No claim is made that server HTML can suppress a client mod HUD.

View file

@ -5,12 +5,15 @@ import org.bukkit.entity.Player;
/** Uses the existing installed MC GUI canvas transport, with the supplied menu definitions. */
final class CanvasProvider implements FullscreenProvider {
private final DuneMenusPlugin plugin;
CanvasProvider(DuneMenusPlugin plugin){this.plugin=plugin;}
private final MenuArt art;private boolean prepared;
CanvasProvider(DuneMenusPlugin plugin){this.plugin=plugin;this.art=new MenuArt(plugin);var services=plugin.getServer().getPluginManager().getPlugin("DunerealmsGUI");if(services!=null)try{art.prepare(services.getDataFolder().toPath().resolve("mcgui"));prepared=true;}catch(Exception failure){plugin.getLogger().warning("Menu artwork preparation failed: "+failure.getClass().getSimpleName());}}
public boolean open(Player player,Screen screen,IntConsumer select,Runnable close){
var services=plugin.getServer().getPluginManager().getPlugin("DunerealmsGUI");
if(services==null||!services.isEnabled())return false;
Map<Integer,String> images=new HashMap<>();
try{if(prepared)for(Card card:screen.cards()){var inventory=screen.contents();if(card.slot()>=0&&card.slot()<inventory.length){String image=art.image(inventory[card.slot()]);if(!image.isEmpty())images.put(card.slot(),image);}}}catch(Exception failure){plugin.getLogger().warning("Menu artwork unavailable: "+failure.getClass().getSimpleName());}
Map<Integer,Runnable> actions=new HashMap<>();for(Card card:screen.cards())actions.put(card.slot(),()->select.accept(card.slot()));
try{return Boolean.TRUE.equals(services.getClass().getMethod("presentSuppliedMenu",Player.class,String.class,String.class,Map.class,Runnable.class).invoke(services,player,screen.title(),SuppliedDocument.html(screen.id(),screen.title(),screen.subtitle(),screen.cards(),screen.info()),actions,close));}
try{return Boolean.TRUE.equals(services.getClass().getMethod("presentSuppliedMenu",Player.class,String.class,String.class,Map.class,Runnable.class).invoke(services,player,screen.title(),SuppliedDocument.html(screen.id(),screen.title(),screen.subtitle(),screen.cards(),screen.info(),images),actions,close));}
catch(ReflectiveOperationException failure){plugin.getLogger().warning("Menu canvas unavailable: "+failure.getClass().getSimpleName());return false;}
}
}

View file

@ -0,0 +1,42 @@
package com.dunerealms.menus;
import java.nio.file.*;
import java.util.*;
import java.util.jar.JarFile;
import com.google.gson.*;
import org.bukkit.inventory.ItemStack;
/** Local, cached references to the exact central-pack item artwork; never invents a quality or model. */
final class MenuArt {
private final DuneMenusPlugin plugin;
private final Map<String,String> paths=new HashMap<>();
MenuArt(DuneMenusPlugin plugin){this.plugin=plugin;}
void prepare(Path root)throws Exception{
try(var jar=new JarFile(Path.of(plugin.getClass().getProtectionDomain().getCodeSource().getLocation().toURI()).toFile())){
var entries=jar.entries();while(entries.hasMoreElements()){
var entry=entries.nextElement();String name=entry.getName();if(entry.isDirectory()||!name.startsWith("menu-art/"))continue;
String relative=name.substring(9);if(!relative.endsWith(".png"))continue;
Path target=root.resolve(relative).normalize();if(!target.startsWith(root.normalize()))throw new IllegalArgumentException("Invalid artwork path");
Files.createDirectories(target.getParent());try(var in=jar.getInputStream(entry)){Files.copy(in,target,StandardCopyOption.REPLACE_EXISTING);}
}
}
}
String image(ItemStack item){
if(item==null||item.getType().isAir())return "";
var meta=item.getItemMeta();String key=meta!=null&&meta.hasItemModel()?meta.getItemModel().toString():"minecraft:"+item.getType().name().toLowerCase(Locale.ROOT);
return paths.computeIfAbsent(key,this::resolve);
}
private String resolve(String key){
if(!key.matches("[a-z0-9_]+:[a-z0-9_/.-]+")||key.contains(".."))return "";
String[] id=key.split(":",2);
if(id[0].equals("minecraft"))return exists("pack/assets/minecraft/textures/item/"+id[1]+".png");
try{
JsonObject definition=json("pack/assets/"+id[0]+"/items/"+id[1]+".json");if(definition==null)return "";
var model=definition.getAsJsonObject("model");if(model==null||!model.get("type").getAsString().equals("minecraft:model"))return "";
String[] ref=model.get("model").getAsString().split(":",2);if(ref.length!=2)return "";
var data=json("pack/assets/"+ref[0]+"/models/"+ref[1]+".json");if(data==null||!data.has("textures"))return "";
var textures=data.getAsJsonObject("textures");if(!textures.has("layer0"))return "";
String[] texture=textures.get("layer0").getAsString().split(":",2);return texture.length==2?exists("pack/assets/"+texture[0]+"/textures/"+texture[1]+".png"):"";
}catch(RuntimeException invalid){return "";}
}
private String exists(String path){if(path.contains("..")||!path.matches("[a-zA-Z0-9_/.-]+"))return "";try(var input=plugin.getResource("menu-art/"+path)){return input==null?"":path;}catch(java.io.IOException failure){return "";}}
private JsonObject json(String path){if(path.contains(".."))return null;try(var input=plugin.getResource("menu-art/"+path)){return input==null?null:JsonParser.parseReader(new java.io.InputStreamReader(input,java.nio.charset.StandardCharsets.UTF_8)).getAsJsonObject();}catch(Exception failure){return null;}}
}

View file

@ -20,7 +20,7 @@ final class ServiceMenu extends Menu {
Inventory inventory, Map<Integer, Runnable> actions) {
super(plugin, player, null);
this.section = section;
this.title = title.replaceFirst("^NPC (dashboard|turn-in) · ", "");
this.title = displayTitle(title);
this.subtitle = description.lines().findFirst().orElse("");
this.cards = inventory.getContents();
this.actions = uniqueActions(actions);
@ -28,6 +28,8 @@ final class ServiceMenu extends Menu {
this.world = player.getWorld().getUID();
}
static String displayTitle(String title) { return title.replaceFirst("^NPC (dashboard|turn-in) · ", "").replaceFirst("^Your Mentat · ", "Your House adviser · "); }
static Map<Integer,Runnable> uniqueActions(Map<Integer,Runnable> actions) {
var seen=java.util.Collections.newSetFromMap(new java.util.IdentityHashMap<Runnable,Boolean>());
var result=new java.util.TreeMap<Integer,Runnable>();

View file

@ -2,18 +2,25 @@ package com.dunerealms.menus;
import java.util.*;
/** Dedicated presentation for the supplied menu definitions. Each card invokes its original slot directly. */
final class SuppliedDocument {
static String escape(String s){return s==null?"":s.replace("&","&amp;").replace("<","&lt;").replace(">","&gt;").replace("\"","&quot;").replace("'","&#39;");}
static String clean(String s){return s==null?"":s.replaceAll("(?i)§[0-9a-fk-orx]","").replaceAll("[\\p{Co}\\p{Cc}&&[^\\n]]","").replace("\uFFFD","").trim();}
static String escape(String s){return clean(s).replace("&","&amp;").replace("<","&lt;").replace(">","&gt;").replace("\"","&quot;").replace("'","&#39;");}
static String accent(String id){return switch(id){case "travel"->"#7fd6e8";case "clan"->"#4fbf8a";case "company"->"#5cc8d6";case "spice"->"#e07b2e";case "war"->"#d2584a";case "politics"->"#b07ce8";case "missions"->"#9fc27a";case "equipment"->"#7fb2d9";default->"#d4ad5a";};}
static String symbol(Card c){return switch(c.material()){case "compass"->"✥";case "emerald"->"◆";case "anvil"->"⚒";case "writable_book","book"->"▤";case "white_banner","green_banner"->"⚑";case "gold_block","gold_ingot"->"◈";case "blaze_powder"->"✦";case "lectern"->"♜";case "player_head"->"♟";case "nether_star"->"✷";case "arrow"->"←";case "barrier"->"×";default->"◇";};}
static String html(String id,String title,String subtitle,List<Card> cards,List<String> info){
static List<String> lines(String text,int width){List<String> out=new ArrayList<>();String rest=clean(text);while(rest.length()>width){int split=rest.lastIndexOf(' ',width);if(split<width/2)split=width;out.add(rest.substring(0,split));rest=rest.substring(split).stripLeading();}if(!rest.isBlank())out.add(rest);return out;}
static List<String> summary(Card card){List<String> out=new ArrayList<>();for(String line:card.lore())out.addAll(lines(line,30));return out;}
static String image(Card c,Map<Integer,String> images){String image=images.getOrDefault(c.slot(),"");return image.matches("pack/assets/[a-z0-9_/.-]+\\.png")&&!image.contains("..")?"<img class='item-icon' src='"+image+"'>":symbol(c);}
static String kind(Card c){if(!c.material().equals("arrow"))return "card";String t=clean(c.title()).toLowerCase(Locale.ROOT);return t.contains("back")?"back":t.contains("previous")||t.contains("next")?"pager":"card";}
static String html(String id,String title,String subtitle,List<Card> cards,List<String> info){return html(id,title,subtitle,cards,info,Map.of());}
static String html(String id,String title,String subtitle,List<Card> cards,List<String> info,Map<Integer,String> images){
String layout=switch(id){case "travel"->"constellation";case "clan","company","house","politics"->"council";case "missions","war"->"journal";case "bank","atm","withdraw","transfer"->"bank";default->"doors";};
StringBuilder b=new StringBuilder("<!doctype html><html><head><meta charset='UTF-8'><style>").append(CSS).append("</style></head><body style='--accent:").append(accent(id)).append("'><div class='frame ").append(escape(id)).append("'><header><div class='brand'>✦<span>DUNE<br>REALMS</span></div><div class='heading'><small>THE IMPERIAL CONCOURSE</small><h1>").append(escape(title)).append("</h1></div><button class='close' data-slot='-1'>×</button></header><div class='scene'><div class='moon'></div><div class='dune rear'></div><div class='dune front'></div><p class='quote'>").append(escape(subtitle)).append("</p>");
StringBuilder b=new StringBuilder("<!doctype html><html><head><meta charset='UTF-8'><style>").append(CSS).append("</style></head><body style='--accent:").append(accent(id)).append("'><div class='frame ").append(escape(id)).append("'><header><div class='brand'><img class='brand-logo' src='art/logo.png'></div><div class='heading'><small>THE IMPERIAL CONCOURSE</small><h1>").append(escape(title)).append("</h1></div><button class='close' data-slot='-1'>×</button></header><div class='scene'><div class='moon'></div><div class='dune rear'></div><div class='dune front'></div><p class='quote'>").append(escape(subtitle)).append("</p>");
if(layout.equals("constellation"))b.append("<div class='orbit one'></div><div class='orbit two'></div><div class='guild'>✷<span>SPACING GUILD</span></div>");
b.append("<main class='").append(layout).append("'>");int index=0;
for(Card c:cards){b.append("<button class='").append(c.material().equals("arrow")?(c.title().toLowerCase(Locale.ROOT).contains("back")?"back":"pager"):"card").append(" n").append(index++).append("' data-slot='").append(c.slot()).append("'><span class='emblem'>").append(symbol(c)).append("</span><div><h2>").append(escape(c.title())).append("</h2>");for(String line:c.lore())if(!line.isBlank())b.append("<p>").append(escape(line)).append("</p>");b.append("</div></button>");}
b.append("</main><section class='facts'>");for(String line:info)b.append("<p>").append(escape(line)).append("</p>");return b.append("</section></div><footer><span class='seal'>◆ J.A.R.V.I.S. ◆</span></footer></div></body></html>").toString();
int summaryLimit=layout.equals("constellation")?1:3;
for(Card c:cards){b.append("<button class='").append(kind(c)).append(" n").append(index++).append("' data-slot='").append(c.slot()).append("'><span class='emblem'>").append(image(c,images)).append("</span><div><h2>");var titleLines=lines(c.title(),24);for(int n=0;n<Math.min(2,titleLines.size());n++){if(n>0)b.append("<br>");b.append(escape(titleLines.get(n)));}if(titleLines.size()>2)b.append("…");b.append("</h2>");var summary=summary(c);for(int n=0;n<Math.min(summaryLimit,summary.size());n++)b.append("<p>").append(escape(summary.get(n))).append(n==summaryLimit-1&&summary.size()>summaryLimit?"…":"").append("</p>");b.append("</div></button>");}
b.append("</main><section class='facts'>");for(Card c:cards)if(summary(c).size()>summaryLimit){b.append("<div class='item-details'><h2>").append(escape(c.title())).append("</h2>");for(String line:c.lore())b.append("<p>").append(escape(line)).append("</p>");b.append("</div>");}for(String line:info)b.append("<p>").append(escape(line)).append("</p>");return b.append("</section></div><footer><span class='seal'>◆ J.A.R.V.I.S. ◆</span></footer></div></body></html>").toString();
}
private static final String CSS="""
*{box-sizing:border-box}body{margin:0;padding:12px;background:#03100f;color:#f1e7cd;font-family:Georgia,serif;font-size:13px}button{font-family:Georgia,serif;color:#f4df9d;cursor:pointer}.frame{min-height:570px;border:2px solid #b69149;outline:1px solid #645334;outline-offset:5px;background:#081e1b;position:relative;overflow:hidden}header{height:78px;border-bottom:2px solid #ae8943;background:linear-gradient(90deg,#102f29,#041512);display:flex;align-items:center;padding:8px 22px;gap:22px}.brand{display:flex;align-items:center;gap:8px;color:#d6ad58;font-size:38px;border-right:1px solid #7c683b;padding-right:20px}.brand span{font-size:16px;line-height:17px;letter-spacing:3px}.heading{flex:1}small{font-size:10px;letter-spacing:3px;color:#ad985f}h1{font-size:26px;margin:5px 0 0;color:#eed995;letter-spacing:1px}.close{width:31px;height:31px;border:1px solid #a58b4d;background:#112922;font-size:24px}.scene{position:relative;min-height:411px;padding:0 28px;overflow:hidden;background:linear-gradient(#162d30,#53665a 58%,#a88c52)}.quote{text-align:center;font-style:italic;position:relative;z-index:1;padding:12px 0 8px;margin:0;color:#f4e7bf}.dune{position:absolute;left:-12%;width:125%;height:180px;border-radius:55% 70% 0 0;pointer-events:none}.rear{bottom:0;background:#b4955a;transform:rotate(-8deg)}.front{bottom:-90px;background:#635a38;transform:rotate(9deg)}.moon{position:absolute;right:15%;top:23px;background:#e4dbb6;border-radius:50%;width:45px;height:45px;opacity:.55}main{position:relative;z-index:2}.doors,.bank{display:flex;flex-wrap:wrap;gap:12px;justify-content:center;padding:12px 0 35px}.card{background:linear-gradient(135deg,#173e35,#0c201d);border:1px solid #b59349;box-shadow:inset 0 0 0 3px #0a231f,0 3px 8px #071713;padding:12px;min-height:94px;display:flex;align-items:center;gap:12px;text-align:left;width:22.5%}.card>div{min-width:0;flex:1}.card h2{overflow-wrap:break-word;white-space:normal}.card:hover{background:linear-gradient(135deg,#315c45,#183c32);border-color:#f3d784}.emblem{font-size:34px;color:var(--accent);width:35px;flex-shrink:0;text-align:center}h2{font-size:16px;margin:0 0 6px}p{margin:3px 0;font-size:11px;line-height:1.35;color:#d1d3bc}.back{position:absolute;bottom:2px;left:0;background:#12372c;border:1px solid #ad8c48;padding:7px 12px;display:flex;align-items:center;gap:8px}.pager{border:1px solid #ad8c48;background:#12372c;padding:10px;display:flex;gap:8px;align-items:center}.back .emblem{font-size:17px;width:auto}.back h2{margin:0;font-size:12px}.back p{display:none}.hub .card{width:22%;min-height:89px}.hub .emblem{font-size:30px}.journal{display:flex;flex-direction:column;gap:8px;padding:8px 9% 45px}.journal .card{width:100%;min-height:68px;padding:8px 18px}.journal .card p{display:inline;margin-right:12px}.council{display:flex;flex-wrap:wrap;gap:16px;justify-content:center;padding:20px 8% 44px}.council .card{width:29%;min-height:115px;border-top:3px solid var(--accent)}.bank .card{width:30%;min-height:100px}.travel .scene{background:radial-gradient(ellipse at center,#123a40,#061317)}.travel .dune,.travel .moon{display:none}.constellation{height:350px;position:relative}.constellation .card{position:absolute;width:230px;min-height:83px;border-color:#74aeb6;background:linear-gradient(135deg,#173e43,#091c23)}.constellation .n0{top:0;left:36%}.constellation .n1{top:98px;left:0}.constellation .n2{top:98px;right:0}.constellation .n3{top:225px;left:12%}.constellation .n4{top:225px;right:12%}.constellation .back{bottom:0}.guild{position:absolute;top:168px;left:44%;font-size:52px;color:#c4dcdf;text-align:center}.guild span{display:block;font-size:11px;letter-spacing:2px}.orbit{position:absolute;border:1px solid #467b84;width:62%;height:170px;top:130px;left:19%;border-radius:50%;transform:rotate(24deg)}.orbit.two{transform:rotate(-24deg)}footer{height:76px;padding:9px 22px;background:#0b211c;border-top:1px solid #a88b47;display:flex;align-items:center;gap:22px}.facts{position:relative;padding:12px 0 24px;z-index:2}.facts p{font-size:11px;color:#c0c9b2}.seal{font-size:10px;letter-spacing:2px;color:#bda464}.war .scene{background:linear-gradient(#2e2424,#182c26)}.spice .scene{background:linear-gradient(#715232,#bc9251)}.politics .scene{background:linear-gradient(#2f2444,#132c27)}
*{box-sizing:border-box}body{margin:0;padding:12px;background:#03100f;color:#f1e7cd;font-family:Georgia,serif;font-size:13px}button{font-family:Georgia,serif;color:#f4df9d;cursor:pointer}.frame{min-height:570px;border:2px solid #b69149;outline:1px solid #645334;outline-offset:5px;background:#081e1b;position:relative;overflow:hidden}header{height:78px;border-bottom:2px solid #ae8943;background:linear-gradient(90deg,#102f29,#041512);display:flex;align-items:center;padding:8px 22px;gap:22px}.brand{display:flex;align-items:center;gap:8px;color:#d6ad58;font-size:38px;border-right:1px solid #7c683b;padding-right:20px}.brand span{font-size:16px;line-height:17px;letter-spacing:3px}.heading{flex:1}small{font-size:10px;letter-spacing:3px;color:#ad985f}h1{font-size:26px;margin:5px 0 0;color:#eed995;letter-spacing:1px}.close{width:31px;height:31px;border:1px solid #a58b4d;background:#112922;font-size:24px}.scene{position:relative;min-height:411px;padding:0 28px;overflow:hidden;background:linear-gradient(#162d30,#53665a 58%,#a88c52)}.quote{text-align:center;font-style:italic;position:relative;z-index:1;padding:12px 0 8px;margin:0;color:#f4e7bf}.dune{position:absolute;left:-12%;width:125%;height:180px;border-radius:55% 70% 0 0;pointer-events:none}.rear{bottom:0;background:#b4955a;transform:rotate(-8deg)}.front{bottom:-90px;background:#635a38;transform:rotate(9deg)}.moon{position:absolute;right:15%;top:23px;background:#e4dbb6;border-radius:50%;width:45px;height:45px;opacity:.55}main{position:relative;z-index:2}.doors,.bank{display:flex;flex-wrap:wrap;gap:12px;justify-content:center;align-items:flex-start;padding:12px 0 35px}.card{background:linear-gradient(135deg,#173e35,#0c201d);border:1px solid #b59349;box-shadow:inset 0 0 0 3px #0a231f,0 3px 8px #071713;padding:12px;height:174px;display:block;text-align:left;width:22.5%;overflow:hidden}.card>div{width:100%;min-width:0}.card .emblem{display:block;float:left;width:44px;height:44px;margin:0 10px 6px 0}.item-icon{width:44px;height:44px;object-fit:contain;image-rendering:pixelated}.brand-logo{width:158px;height:58px;object-fit:contain}.brand{width:180px;flex-shrink:0}.card h2{line-height:1.2}.card p{line-height:1.25;white-space:normal;overflow-wrap:break-word}.item-details{border:1px solid #786338;background:#102a24;margin-top:12px;padding:16px}.item-details p{overflow-wrap:break-word}.card h2{overflow-wrap:break-word;white-space:normal}.card:hover{background:linear-gradient(135deg,#315c45,#183c32);border-color:#f3d784}.emblem{font-size:34px;color:var(--accent);width:35px;flex-shrink:0;text-align:center}h2{font-size:16px;margin:0 0 6px}p{margin:3px 0;font-size:11px;line-height:1.35;color:#d1d3bc}.back{position:absolute;bottom:2px;left:0;background:#12372c;border:1px solid #ad8c48;padding:7px 12px;display:flex;align-items:center;gap:8px}.pager{border:1px solid #ad8c48;background:#12372c;padding:10px;display:flex;gap:8px;align-items:center}.back .emblem{font-size:17px;width:auto}.back h2{margin:0;font-size:12px}.back p{display:none}.hub .card{width:22%;min-height:89px}.hub .emblem{font-size:30px}.journal{display:flex;flex-direction:column;gap:8px;padding:8px 9% 45px}.journal .card{width:100%;height:auto;min-height:68px;padding:8px 18px}.journal .card p{display:inline;margin-right:12px}.council{display:flex;flex-wrap:wrap;gap:16px;justify-content:center;padding:20px 8% 44px}.council .card{width:46%;height:174px;min-height:115px;border-top:3px solid var(--accent)}.bank .card{width:30%;min-height:100px}.travel .scene{background:radial-gradient(ellipse at center,#123a40,#061317)}.travel .dune,.travel .moon{display:none}.constellation{height:350px;position:relative}.constellation .card{position:absolute;width:230px;height:90px;min-height:83px;border-color:#74aeb6;background:linear-gradient(135deg,#173e43,#091c23)}.constellation .card .emblem{display:none}.constellation .n0{top:0;left:36%}.constellation .n1{top:98px;left:0}.constellation .n2{top:98px;right:0}.constellation .n3{top:225px;left:12%}.constellation .n4{top:225px;right:12%}.constellation .back{bottom:0}.guild{position:absolute;top:168px;left:44%;font-size:52px;color:#c4dcdf;text-align:center}.guild span{display:block;font-size:11px;letter-spacing:2px}.orbit{position:absolute;border:1px solid #467b84;width:62%;height:170px;top:130px;left:19%;border-radius:50%;transform:rotate(24deg)}.orbit.two{transform:rotate(-24deg)}footer{height:76px;padding:9px 22px;background:#0b211c;border-top:1px solid #a88b47;display:flex;align-items:center;gap:22px}.facts{position:relative;padding:12px 0 24px;z-index:2}.facts p{font-size:11px;color:#c0c9b2}.seal{font-size:10px;letter-spacing:2px;color:#bda464}.war .scene{background:linear-gradient(#2e2424,#182c26)}.spice .scene{background:linear-gradient(#715232,#bc9251)}.politics .scene{background:linear-gradient(#2f2444,#132c27)}
""";
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 685 KiB

View file

@ -3,9 +3,10 @@ import java.nio.file.*;import java.util.*;import java.awt.geom.*;import javax.im
public class RendererVerification {
public static void main(String[]args)throws Exception{
Path dir=Path.of(args[0]);Files.createDirectories(dir);var loader=new Page.Loader(false,dir.resolve("engine-cache"));int checked=0;
Files.createDirectories(dir.resolve("art"));Files.copy(Path.of("src/main/resources/menu-art/art/logo.png"),dir.resolve("art/logo.png"),StandardCopyOption.REPLACE_EXISTING);
for(String id:List.of("hub","travel","exchange","clan","company","missions","spice","war","politics","house","equipment","bank","atm","withdraw","transfer")){
List<Card> cards=new ArrayList<>();int count=id.equals("exchange")?28:id.equals("travel")?5:8;
for(int n=0;n<count;n++)cards.add(new Card(n,(n==0?"Imperial Postbank":"Entry "+(n+1)),List.of("Verified service detail","Amount: 100.00 DM"),id.equals("travel")?"compass":"emerald"));
for(int n=0;n<count;n++)cards.add(new Card(n,(n==0?"Imperial Postbank · very long official account title":"Entry "+(n+1)),n==0?List.of("Personal level, Reputation and active quests","LEGENDARY | MK XIV","Efficiency VIII","Fortune IV","Mending I","Unbreaking IV","Amount: 100.00 DM"):List.of("Verified service detail","Amount: 100.00 DM"),id.equals("travel")?"compass":"emerald"));
cards.add(new Card(45,"Back",List.of(),"arrow"));
String html=SuppliedDocument.html(id,"DuneRealms · "+id,"Service information",cards,List.of("Read-only account and permission details"));
Path file=dir.resolve(id+"-matrix.html");Files.writeString(file,html);var page=Page.of(html,file,loader);var frame=HtmlRenderer.render(page,1536,896,1.5,0,Selector.State.NONE);
@ -14,6 +15,7 @@ public class RendererVerification {
for(Card card:cards){
var element=page.document.selectFirst("[data-slot='"+card.slot()+"']");var bounds=frame.boundsOf(element);
if(bounds==null||bounds.getWidth()<=0||bounds.getHeight()<=0)throw new AssertionError(id+" invisible slot "+card.slot());
for(var text:element.select("h2,p")){var box=frame.boundsOf(text);if(box!=null&&(box.getMinX()<bounds.getMinX()-1||box.getMaxX()>bounds.getMaxX()+1||box.getMinY()<bounds.getMinY()-1||box.getMaxY()>bounds.getMaxY()+1))throw new AssertionError(id+" text outside card "+card.slot()+" text="+box+" card="+bounds);}
double scroll=Math.max(0,Math.min(frame.maxScroll(),bounds.getCenterY()-260));var visible=HtmlRenderer.render(page,1536,896,1.5,scroll,Selector.State.NONE);
var at=visible.elementAt(bounds.getCenterX(),bounds.getCenterY()-scroll);var button=at==null?null:at.closest("[data-slot]");
if(button==null||!button.attr("data-slot").equals(""+card.slot()))throw new AssertionError(id+" hit slot "+card.slot()+" at "+bounds+" scroll="+scroll+" got="+button);
@ -21,6 +23,10 @@ public class RendererVerification {
}
System.out.println(id+": parser clean; "+cards.size()+" action hitboxes; maxScroll="+frame.maxScroll());
}
var actualIcon=Path.of("../network/resource-pack/central/overlay/assets/dunerealms/textures/item/equipment/legendary_mk14_axe.png");Path iconTarget=dir.resolve("pack/assets/dunerealms/textures/item/equipment/legendary_mk14_axe.png");Files.createDirectories(iconTarget.getParent());Files.copy(actualIcon,iconTarget,StandardCopyOption.REPLACE_EXISTING);
var listing=new Card(13,"\uE400§6Paul's chopper",List.of("LEGENDARY | MK XIV","Used by Paul himself.","Efficiency VIII","Fortune IV","Mending I","Unbreaking IV","Seller: J.A.R.V.I.S. HQ","1 available · 500.00 DM each"),"netherite_axe");
String listingHtml=SuppliedDocument.html("exchange","Exchange · Buy","Authoritative item artwork",List.of(new Card(9,"Buy",List.of("Browse available items"),"emerald"),listing),List.of(),Map.of(13,"pack/assets/dunerealms/textures/item/equipment/legendary_mk14_axe.png"));
var listingPage=Page.of(listingHtml,dir.resolve("exchange-item.html"),loader);var listingFrame=HtmlRenderer.render(listingPage,1536,896,1.5,0,Selector.State.NONE);if(!listingPage.problems.isEmpty())throw new AssertionError(listingPage.problems.toString());ImageIO.write(listingFrame.image(),"png",dir.resolve("exchange-item-engine.png").toFile());
System.out.println("PASS: "+checked+" direct action hitboxes across15 menu families.");
}
}

View file

@ -29,4 +29,23 @@ class SuppliedDocumentTest {
assertTrue(SuppliedDocument.html("travel","Passage","",List.of(),List.of()).contains("main class='constellation'"));
assertTrue(SuppliedDocument.html("missions","Journal","",List.of(),List.of()).contains("main class='journal'"));
}
@Test void legacyFormattingIsRemovedWithoutLosingItemNamesOrMarks(){
assertEquals("Paul's chopper",SuppliedDocument.clean("\uE400§6Paul's chopper\uE401"));
assertEquals("LEGENDARY | MK XIV",SuppliedDocument.clean("§x§f§f§0§0§a§aLEGENDARY | MK XIV"));
}
@Test void longListingLoreIsBoundedInCardsAndRetainedInDetails(){
var lore=List.of("LEGENDARY | MK XIV","Used by Paul himself.","Efficiency VIII","Fortune IV","Mending I","Unbreaking IV","Seller: JARVIS HQ","1 available · 500 DM each");
String html=SuppliedDocument.html("exchange","Buy","",List.of(new Card(13,"Paul's chopper",lore,"netherite_axe")),List.of());
String button=html.substring(html.indexOf("data-slot='13'"),html.indexOf("</button>",html.indexOf("data-slot='13'")));
assertFalse(button.contains("Mending I"));assertTrue(html.contains("class='item-details'"));assertTrue(html.contains("Mending I"));assertTrue(html.contains("data-slot='13'"));
}
@Test void adviserLabelDoesNotInventANpcProfession(){assertEquals("Your House adviser · Stilgar",ServiceMenu.displayTitle("Your Mentat · Stilgar"));assertEquals("Exchange · Buy",ServiceMenu.displayTitle("Exchange · Buy"));}
@Test void houseArrowIsAnOrdinaryCardAndEveryWrappedLineIsBounded(){
assertEquals("card",SuppliedDocument.kind(new Card(45,"Your House",List.of(),"arrow")));
for(String line:SuppliedDocument.lines("Personal level, Reputation and active quests with a verylongunbrokenwordthatmustalsofit",24))assertTrue(line.length()<=24);
}
@Test void localArtworkPathsAreEscapedAndNeverRemoteOrTraversable(){
var card=new Card(13,"Axe",List.of(),"netherite_axe");assertTrue(SuppliedDocument.image(card,java.util.Map.of(13,"pack/assets/dunerealms/textures/item/equipment/legendary_mk14_axe.png")).contains("<img"));
assertFalse(SuppliedDocument.image(card,java.util.Map.of(13,"https://evil/image.png")).contains("<img"));assertFalse(SuppliedDocument.image(card,java.util.Map.of(13,"pack/assets/../secret.png")).contains("<img"));
}
}

View file

@ -1,6 +1,6 @@
plugins { java }
group = "com.dunerealms"
version = "1.1.35"
version = "1.1.36"
repositories { mavenCentral(); maven("https://repo.papermc.io/repository/maven-public/"); maven("https://repo.opencollab.dev/main/") }
dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")

View file

@ -94,10 +94,10 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
@Override public void onDisable(){if(modernMenus!=null)modernMenus.close();if(nameplates!=null)nameplates.close();if(exchange!=null)exchange.close();if(itemPreviews!=null)itemPreviews.close();if(quests!=null)quests.close();requests.clear();records.clear();bookings.clear();boarding.clear();if(guild!=null)guild.close();GuiSession.clear();if(sidebar!=null)sidebar.clear();for(var controller:detached.values())try{controller.restore();}catch(ReflectiveOperationException ignored){}detached.clear();if(departure!=null)departure.removeAll();for(Player p:Bukkit.getOnlinePlayers())if(p.getOpenInventory().getTopInventory().getHolder() instanceof Screen)p.closeInventory();}
private boolean lobby(Player p){return p.getWorld().getName().equals("guild_lobby");}
@Override public boolean onCommand(CommandSender sender,Command command,String label,String[] args){
if(sender instanceof Player player&&ExchangeEntryPoint.matches(command.getName(),args)){exchange.open(player);return true;}
if(sender instanceof Player supplied&&SuppliedMenus.command(supplied,command.getName(),args))return true;
if(sender instanceof Player p&&command.getName().equals("sellall")){spice.sellAll(p,args.length==0?"guild":args[0].toLowerCase(Locale.ROOT));return true;}
if(sender instanceof Player p&&(command.getName().equals("spice")||command.getName().equals("drgui")&&args.length==1&&args[0].equalsIgnoreCase("spice"))){spice.open(p);return true;}
if(sender instanceof Player player&&(command.getName().equals("exchange")||command.getName().equals("drgui")&&args.length==1&&args[0].equalsIgnoreCase("exchange"))){exchange.open(player);return true;}
if(sender instanceof Player player&&command.getName().equals("drgui")&&args.length>0&&args[0].equalsIgnoreCase("previewitem")){try{if(args.length!=3)throw new IllegalArgumentException();int revision=Integer.parseInt(args[2]);if(revision<1||revision>999999)throw new IllegalArgumentException();itemPreviews.open(player,UUID.fromString(args[1]),revision);}catch(IllegalArgumentException invalid){player.sendMessage("Use /drgui previewitem <saved-design-id> <revision>");}return true;}
if(sender instanceof Player player&&command.getName().equals("drgui")&&args.length==1&&args[0].equalsIgnoreCase("quests")){quests.open(player);return true;}
if(sender instanceof Player player&&command.getName().equals("drgui")&&args.length==2&&args[0].equalsIgnoreCase("movenpc")){polQuestNpcs.move(player,args[1]);return true;}
@ -188,7 +188,7 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
@EventHandler(priority=EventPriority.HIGHEST,ignoreCancelled=false) public void organisationContact(org.bukkit.event.player.PlayerInteractEntityEvent event){String marker=event.getRightClicked().getPersistentDataContainer().get(new NamespacedKey("dunerealms","organisation_home_npc"),PersistentDataType.STRING);if(marker==null)return;event.setCancelled(true);if(event.getHand()!=org.bukkit.inventory.EquipmentSlot.HAND)return;String[] parts=marker.split(":",2);if(parts.length!=2||!Set.of("clan","company").contains(parts[0]))return;try{String id=UUID.fromString(parts[1]).toString();organisations.openHomeNpc(event.getPlayer(),parts[0].equals("clan")?"clans":"companies",id);}catch(IllegalArgumentException ignored){}}
@EventHandler public void scoreboardCommand(PlayerCommandPreprocessEvent e){String command=e.getMessage().trim();if(command.equalsIgnoreCase("/scoreboard")){e.setCancelled(true);toggleSidebar(e.getPlayer());}}
@EventHandler(priority=EventPriority.HIGHEST) public void oldNavigator(PlayerInteractEvent e){if(e.getHand()!=EquipmentSlot.HAND||e.getItem()==null||!e.getItem().hasItemMeta()||!e.getAction().isRightClick())return;var data=e.getItem().getItemMeta().getPersistentDataContainer();for(var key:data.getKeys())if(data.has(key,PersistentDataType.STRING)&&"menu_opener".equals(data.get(key,PersistentDataType.STRING))){e.setCancelled(true);if(!SuppliedMenus.open(e.getPlayer(),"hub"))organisations.console(e.getPlayer());return;}}
@EventHandler(priority=EventPriority.LOWEST,ignoreCancelled=true) public void legacyTravel(PlayerCommandPreprocessEvent e){String[] args=e.getMessage().substring(1).trim().toLowerCase(Locale.ROOT).split("\\s+");String label=args[0].replaceFirst("^[^:]+:","");if(label.equals("balance")||label.equals("bal")||label.equals("money")){e.setCancelled(true);if(!sidebar.enabled(e.getPlayer()))sidebar.toggle(e.getPlayer());refreshSidebar(e.getPlayer());return;}if(label.equals("exchange")){e.setCancelled(true);if(!SuppliedMenus.open(e.getPlayer(),"exchange"))exchange.open(e.getPlayer());return;}if(label.equals("server")||label.equals("duneess")&&args.length>1&&args[1].equals("travel")){e.setCancelled(true);if(!SuppliedMenus.open(e.getPlayer(),"travel"))openGuild(e.getPlayer(),null);}}
@EventHandler(priority=EventPriority.LOWEST,ignoreCancelled=true) public void legacyTravel(PlayerCommandPreprocessEvent e){String[] args=e.getMessage().substring(1).trim().toLowerCase(Locale.ROOT).split("\\s+");String label=args[0].replaceFirst("^[^:]+:","");if(label.equals("balance")||label.equals("bal")||label.equals("money")){e.setCancelled(true);if(!sidebar.enabled(e.getPlayer()))sidebar.toggle(e.getPlayer());refreshSidebar(e.getPlayer());return;}if(label.equals("exchange")){e.setCancelled(true);exchange.open(e.getPlayer());return;}if(label.equals("server")||label.equals("duneess")&&args.length>1&&args[1].equals("travel")){e.setCancelled(true);if(!SuppliedMenus.open(e.getPlayer(),"travel"))openGuild(e.getPlayer(),null);}}
private void offerGuiPack(Player p){offerGuiPack(p,true);}
private void offerGuiPack(Player p,boolean force){
if(p.isOnline()&&!BedrockForms.isBedrock(p))MCGUIMenus.offerPack(p);

View file

@ -0,0 +1,6 @@
package com.dunerealms.gui;
/** Route command aliases to the same native Exchange service as the GUI button. */
final class ExchangeEntryPoint {
private ExchangeEntryPoint(){}
static boolean matches(String command,String[] args){String label=command.replaceFirst("^[^:]+:","");return label.equalsIgnoreCase("exchange")||label.equalsIgnoreCase("drgui")&&args.length==1&&args[0].equalsIgnoreCase("exchange");}
}

View file

@ -0,0 +1,7 @@
package com.dunerealms.gui;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class ExchangeEntryPointTest {
@Test void publicAndNamespacedExchangeAliasesUseTheNativeService(){for(String command:new String[]{"exchange","dunerealmsgui:exchange","duneess:exchange","EXCHANGE"})assertTrue(ExchangeEntryPoint.matches(command,new String[0]));assertTrue(ExchangeEntryPoint.matches("drgui",new String[]{"exchange"}));}
@Test void otherMenusAndMalformedArgumentsKeepTheirOwnRoutes(){assertFalse(ExchangeEntryPoint.matches("spice",new String[0]));assertFalse(ExchangeEntryPoint.matches("drgui",new String[0]));assertFalse(ExchangeEntryPoint.matches("drgui",new String[]{"exchange","buy"}));}
}