Guard the Navigator release against deployed plugin runtimes

This commit is contained in:
unimatrixgit 2026-11-29 23:44:50 +01:00
commit 9baca377a7

View file

@ -40,6 +40,7 @@ public class RendererVerification {
}
System.out.println(id+": parser clean; "+cards.size()+" action hitboxes; maxScroll="+frame.maxScroll()+"; render-and-hitbox-ms="+((System.nanoTime()-started)/1_000_000));
}
verifyNavigators(dir,loader);
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);
for(String name:List.of("item/iron_sword","block/cobblestone")){Path target=dir.resolve("pack/assets/minecraft/textures/"+name+".png");Files.createDirectories(target.getParent());Files.copy(Path.of("../network/resource-pack/vanilla-art/overlay/assets/minecraft/textures/"+name+".png"),target,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");
@ -48,4 +49,59 @@ public class RendererVerification {
for(var element:listingPage.document.select(".market-tool,[data-slot='1013']")){var bounds=listingFrame.boundsOf(element);var at=listingFrame.elementAt(bounds.getCenterX(),bounds.getCenterY());if(at==null||!at.closest("[data-slot]").attr("data-slot").equals(element.attr("data-slot")))throw new AssertionError("Detail control hitbox");}
System.out.println("PASS: "+checked+" direct action hitboxes across15 menu families.");
}
private static void verifyNavigators(Path dir,Page.Loader loader)throws Exception{
List<Card> guild=List.of(
new Card(4,"Arrakduin",List.of("Fare: 125.00 DM"),"compass"),
new Card(19,"Kaladam",List.of("House passage required"),"gray_dye",false),
new Card(25,"Giedermark",List.of("Current Guild embargo"),"gray_dye",false),
new Card(37,"Kaiterhof",List.of("Fare: 125.00 DM"),"compass"),
new Card(43,"Sigmadraken IV",List.of("World currently offline"),"gray_dye",false),
new Card(45,"Back",List.of(),"arrow"));
var owned=new ArrayList<Card>();
for(int i=0;i<28;i++){
int slot=10+i/7*9+i%7;
owned.add(new Card(slot,"Company Home Block "+(i+1),
List.of(i%2==0?"Kaladam · View fare":"No registered Home Block"),
i%2==0?"cyan_banner":"gray_dye",i%2==0));
}
owned.add(new Card(45,"Back",List.of(),"arrow"));
owned.add(new Card(51,"Next page",List.of(),"arrow"));
var confirm=List.of(new Card(22,"Company Home Block",List.of("Smuggler fare: 125.07 DM"),"compass"),
new Card(31,"Confirm paid passage",List.of("Payment settles after arrival"),"lime_dye"),
new Card(45,"Back",List.of(),"arrow"));
for(var family:Map.of("guild",guild,"esmar",guild,"owned-home",owned,"confirm",confirm).entrySet()){
String name=family.getKey();
var cards=family.getValue();
String html=SuppliedDocument.html(name.equals("guild")?"travel":"smuggler","Smuggler Navigator","Choose a destination",cards,List.of());
var page=Page.of(html,dir.resolve(name+"-navigator.html"),loader);
var frame=HtmlRenderer.render(page,1536,896,1.5,0,Selector.State.NONE);
if(!page.problems.isEmpty())throw new AssertionError(name+" parser problems "+page.problems);
var rendered=page.document.select("main > *");
if(rendered.size()!=cards.size())throw new AssertionError(name+" duplicate or missing rows: "+rendered.size());
for(int index=0;index<cards.size();index++){
Card card=cards.get(index);
var element=rendered.get(index);
var bounds=frame.boundsOf(element);
if(bounds==null||bounds.isEmpty())throw new AssertionError(name+" invisible "+card.title());
if(!card.enabled()&&(!element.hasClass("locked")||!element.select("[data-slot]").isEmpty()||element.hasAttr("data-slot")))
throw new AssertionError(name+" disabled destination has an action "+card.title());
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(name+" text outside card "+card.title()+": "+box+" vs "+bounds);
}
if(card.enabled()){
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 hit=visible.elementAt(bounds.getCenterX(),bounds.getCenterY()-scroll);
if(hit==null||hit.closest("[data-slot]")==null||!hit.closest("[data-slot]").attr("data-slot").equals(""+card.slot()))
throw new AssertionError(name+" unreachable action "+card.title());
}
}
ImageIO.write(frame.image(),"png",dir.resolve(name+"-navigator-engine.png").toFile());
System.out.println(name+" navigator: "+cards.size()+" distinct rows, contained text, disabled routes have no actions");
}
}
}