Protect shared Builder inventories and add Lobby Multiverse #82
38 changed files with 1666 additions and 51 deletions
52
.forgejo/workflows/compact-menu-links.yml
Normal file
52
.forgejo/workflows/compact-menu-links.yml
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
name: Compact Dune Menu Overlay
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: ['fix/compact-menu-links-*']
|
||||
|
||||
jobs:
|
||||
compact-menu-links:
|
||||
runs-on: dune-ci
|
||||
steps:
|
||||
- name: Check out exact revision
|
||||
shell: bash
|
||||
env:
|
||||
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git init .
|
||||
git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --depth=1 https://www.dunerealms.com/git/unimatrix/plugins.git "$GITHUB_SHA"
|
||||
git checkout --detach FETCH_HEAD
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: '21'
|
||||
- uses: gradle/actions/setup-gradle@v4
|
||||
with:
|
||||
gradle-version: '9.2.1'
|
||||
- name: Test menu routes and package only scoped UI classes
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
for module in DuneRealmsGUI DuneMenus DuneLobby; do
|
||||
gradle --no-daemon -p "$module" test jar
|
||||
done
|
||||
mkdir compact-menu-links
|
||||
PYTHONPATH=tools python3 - <<'PY'
|
||||
from pathlib import Path
|
||||
from plugin_menu_polish import CLASSES
|
||||
from plugin_wild_update import read_archive, write_archive
|
||||
for module, jar in {"gui":"DuneRealmsGUI/build/libs/DunerealmsGUI.jar", "menus":"DuneMenus/build/libs/DuneMenus.jar", "lobby":"DuneLobby/build/libs/DuneRealms-Lobby.jar"}.items():
|
||||
source = read_archive(Path(jar).read_bytes())
|
||||
entries = list(CLASSES[module])
|
||||
if module in ("gui", "menus"): entries.append("com/dunerealms/" + module + "/MenuPolish.class")
|
||||
Path("compact-menu-links/" + module + ".zip").write_bytes(write_archive({e:source[e] for e in entries}))
|
||||
PY
|
||||
cp tools/{plugin_menu_polish.py,plugin_wild_update.py,CompactMenuMerge.java} compact-menu-links/
|
||||
printf '%s\n' "$GITHUB_SHA" > compact-menu-links/SOURCE_COMMIT
|
||||
(cd compact-menu-links && sha256sum -- *.zip *.py *.java SOURCE_COMMIT > SHA256SUMS)
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: DuneRealms-Compact-Menu-Links
|
||||
path: compact-menu-links
|
||||
if-no-files-found: error
|
||||
51
.forgejo/workflows/lobby-builder-safety.yml
Normal file
51
.forgejo/workflows/lobby-builder-safety.yml
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
name: Profile-safe Lobby Builder
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: ['fix/compact-menu-links-*']
|
||||
jobs:
|
||||
builder-safety:
|
||||
runs-on: dune-ci
|
||||
steps:
|
||||
- name: Check out exact revision
|
||||
shell: bash
|
||||
env:
|
||||
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git init .
|
||||
git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --depth=1 https://www.dunerealms.com/git/unimatrix/plugins.git "$GITHUB_SHA"
|
||||
git checkout --detach FETCH_HEAD
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: '21'
|
||||
- uses: gradle/actions/setup-gradle@v4
|
||||
with:
|
||||
gradle-version: '9.2.1'
|
||||
- name: Test inventory isolation and package the scoped classes
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
gradle --no-daemon -p DuneRealms-minecraft-only test jar
|
||||
gradle --no-daemon -p DuneStaff test jar
|
||||
mkdir lobby-builder-safety
|
||||
PYTHONPATH=tools python3 - <<'PY'
|
||||
from pathlib import Path
|
||||
from plugin_builder_multiverse import CORE, BUILDER, CORE_CLASSES, LEASE, BUILDER_CLASSES
|
||||
from plugin_wild_update import read_archive, write_archive
|
||||
for name, jar, entries in [
|
||||
("core", "DuneRealms-minecraft-only/build/libs/DuneRealms-Core.jar", [CORE+n for n in CORE_CLASSES+[LEASE]]),
|
||||
("builder", "DuneStaff/build/libs/DuneStaff.jar", [BUILDER+n for n in BUILDER_CLASSES])
|
||||
]:
|
||||
compiled=read_archive(Path(jar).read_bytes())
|
||||
Path("lobby-builder-safety/"+name+".zip").write_bytes(write_archive({n:compiled[n] for n in entries}))
|
||||
PY
|
||||
cp tools/{plugin_builder_multiverse.py,plugin_wild_update.py,BuilderProfileCoreOverlay.java} lobby-builder-safety/
|
||||
printf '%s\n' "$GITHUB_SHA" > lobby-builder-safety/SOURCE_COMMIT
|
||||
(cd lobby-builder-safety && sha256sum -- *.zip *.py *.java SOURCE_COMMIT > SHA256SUMS)
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: DuneRealms-Lobby-Builder-Safety
|
||||
path: lobby-builder-safety
|
||||
if-no-files-found: error
|
||||
29
.forgejo/workflows/multiverse-core-lobby.yml
Normal file
29
.forgejo/workflows/multiverse-core-lobby.yml
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
name: Reviewed Lobby Multiverse Core
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: ['fix/compact-menu-links-*']
|
||||
jobs:
|
||||
multiverse-core:
|
||||
runs-on: dune-ci
|
||||
steps:
|
||||
- name: Check out exact revision
|
||||
shell: bash
|
||||
env:
|
||||
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git init .
|
||||
git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --depth=1 https://www.dunerealms.com/git/unimatrix/plugins.git "$GITHUB_SHA"
|
||||
git checkout --detach FETCH_HEAD
|
||||
- name: Verify the official Core input and package Lobby configuration
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
python3 tools/test_multiverse_core.py -v
|
||||
python3 tools/stage_multiverse_core.py multiverse-core-lobby "$GITHUB_SHA"
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: DuneRealms-Multiverse-Core-Lobby
|
||||
path: multiverse-core-lobby
|
||||
if-no-files-found: error
|
||||
|
|
@ -180,7 +180,7 @@ public final class DuneLobby extends JavaPlugin implements Listener, CommandExec
|
|||
e.getPlayer().sendMessage("The Spacing Guild menu is unavailable.");
|
||||
}
|
||||
}
|
||||
case "exchange" -> { if(Bukkit.getPluginCommand("dune")!=null) e.getPlayer().performCommand("dune exchange"); else e.getPlayer().sendMessage(ChatColor.GOLD+"Koopkring market integration requires DuneCore on this backend."); }
|
||||
case "exchange" -> { if(!e.getPlayer().performCommand("dunerealmsgui:exchange")) e.getPlayer().sendMessage("The Exchange service is temporarily unavailable."); }
|
||||
case "water","spice" -> trade(e.getPlayer(),role);
|
||||
}
|
||||
}
|
||||
|
|
@ -207,29 +207,11 @@ public final class DuneLobby extends JavaPlugin implements Listener, CommandExec
|
|||
|
||||
}
|
||||
}
|
||||
private void departure(Player player,String planet) {
|
||||
TravelMenu menu=new TravelMenu(planet); ItemStack confirm=new ItemStack(Material.LIME_CONCRETE); ItemMeta meta=confirm.getItemMeta();
|
||||
meta.setDisplayName("Confirm departure: "+planet); meta.setLore(List.of("DuneEss fares and access rules apply when installed.")); confirm.setItemMeta(meta);
|
||||
menu.inventory.setItem(4,confirm);
|
||||
com.example.dunegui.NativeMenus.show(this,player,"Guild departure",List.of(
|
||||
new com.example.dunegui.NativeMenus.Choice("Confirm departure: "+planet,"DuneEss fares and access rules apply.",()->depart(player,planet)),
|
||||
new com.example.dunegui.NativeMenus.Choice("Cancel","",player::closeInventory)));
|
||||
}
|
||||
private void departure(Player player,String planet) { depart(player,planet); }
|
||||
private void depart(Player player,String planet) {
|
||||
long now=System.currentTimeMillis(); if(now-travelCooldown.getOrDefault(player.getUniqueId(),0L)<5000) return;
|
||||
travelCooldown.put(player.getUniqueId(),now);
|
||||
Bukkit.getScheduler().runTask(this,()-> {
|
||||
player.closeInventory();
|
||||
if(Bukkit.getPluginCommand("duneess")!=null) { player.performCommand("duneess travel "+planet); return; }
|
||||
World target=Bukkit.getWorld(planet);
|
||||
if(target!=null) { player.teleport(target.getSpawnLocation()); return; }
|
||||
String server=getConfig().getString("servers."+planet,"");
|
||||
if(server.isBlank()) { player.sendMessage("No destination configured."); return; }
|
||||
try {
|
||||
ByteArrayOutputStream bytes=new ByteArrayOutputStream(); DataOutputStream out=new DataOutputStream(bytes); out.writeUTF("Connect"); out.writeUTF(server);
|
||||
player.sendPluginMessage(this,"BungeeCord",bytes.toByteArray()); player.sendMessage("Guild departure requested. If you remain here, the destination or proxy is unavailable.");
|
||||
} catch(IOException ex) { player.sendMessage("Guild departure could not be requested."); }
|
||||
});
|
||||
// Boarding remains with the authenticated current Guild quote and confirmation flow.
|
||||
if (!player.performCommand("dunerealmsgui:guildtravel"))
|
||||
player.sendMessage("The Spacing Guild menu is temporarily unavailable.");
|
||||
}
|
||||
@EventHandler public void drag(InventoryDragEvent e) { if(e.getView().getTopInventory().getHolder() instanceof TravelMenu) e.setCancelled(true); }
|
||||
@EventHandler public void quit(PlayerQuitEvent e) { travelCooldown.remove(e.getPlayer().getUniqueId()); }
|
||||
|
|
|
|||
91
DuneMenus/docs/menu-audit-20261205.json
Normal file
91
DuneMenus/docs/menu-audit-20261205.json
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
{
|
||||
"scope": "Current six Paper backends; source routes and saved Citizens records; no production payments or quest claims executed",
|
||||
"menuFamilies": [
|
||||
"hub",
|
||||
"travel",
|
||||
"exchange",
|
||||
"clan",
|
||||
"company",
|
||||
"missions",
|
||||
"spice",
|
||||
"war",
|
||||
"politics",
|
||||
"house",
|
||||
"equipment",
|
||||
"bank",
|
||||
"atm",
|
||||
"withdraw",
|
||||
"transfer"
|
||||
],
|
||||
"nativeServiceRoutes": [
|
||||
"hub",
|
||||
"travel",
|
||||
"exchange",
|
||||
"clan",
|
||||
"company",
|
||||
"missions",
|
||||
"spice",
|
||||
"war",
|
||||
"politics",
|
||||
"lore",
|
||||
"cookbook",
|
||||
"mentat",
|
||||
"house",
|
||||
"equipment"
|
||||
],
|
||||
"repairs": [
|
||||
"Explicit current Exchange Broker command",
|
||||
"Departure pads open current authenticated Guild menu without legacy direct teleport fallback",
|
||||
"Guild return menu gains Back to Imperial Codex",
|
||||
"Empty NPC mission views link to the current mission journal",
|
||||
"Cookbook command offered in completion and explicit Codex route",
|
||||
"Permission refusal produces feedback instead of a silent menu"
|
||||
],
|
||||
"guild": {
|
||||
"primaryWorldsWithSavedNavigator": [
|
||||
"arrakis",
|
||||
"caladan",
|
||||
"giedi_prime",
|
||||
"kaitain",
|
||||
"sigma_draconis_iv"
|
||||
],
|
||||
"lobby": "Guild Navigator Liaison",
|
||||
"enabledOnAllSix": true,
|
||||
"otherDimensions": "Guild command and marked-NPC handler are world independent; outside guild_lobby the menu presents the existing central return operation. No new NPC spawned or travel authority bypassed."
|
||||
},
|
||||
"npcPurposeReview": {
|
||||
"savedRecords": 45,
|
||||
"snapshotCaution": "Disk registry snapshot is not a fresh connected-client or spawned-entity census.",
|
||||
"legacyCopies": {
|
||||
"lobby_arrakis": {
|
||||
"unmappedQuestRoles": [
|
||||
"esmar_tuek",
|
||||
"stilgar",
|
||||
"shadout_mapes",
|
||||
"chani",
|
||||
"liet_kynes",
|
||||
"alia_atreides",
|
||||
"war_marshal"
|
||||
],
|
||||
"ambientSmugglerCopies": 3
|
||||
},
|
||||
"lobby_base": {
|
||||
"quartermasterCopy": 1
|
||||
}
|
||||
},
|
||||
"clarity": "Water and spice sellers in Guild Lobby barter explicitly non-redeemable samples; they are not the Arrakis Melange buyers. Dynamic Home Block NPC retains its organisation service. Fixed Esmar starts contracts, Staban receives deliveries. No NPC records removed.",
|
||||
"conditionalRoleReview": {
|
||||
"glossu_rabban": "No built-in branch or fixed decision entry; central dossier/cargo assignments may still give this role work. Verify catalogue before removal.",
|
||||
"irulan_corrino": "No built-in branch or fixed decision entry; central dossier/cargo assignments may still give this role work. Verify catalogue before removal."
|
||||
}
|
||||
},
|
||||
"notClaimed": "Full live client coverage across every faction, permission, quest state, Java and Bedrock remains a separate player validation; fixtures do not spend money, advance quests, or transfer live players.",
|
||||
"localValidation": {
|
||||
"unitTests": 252,
|
||||
"failed": 0,
|
||||
"renderedControls": 334,
|
||||
"renderer": "Exact installed MCGUI 0.8.6",
|
||||
"standardCardWidthAndHeightRatio": 0.75,
|
||||
"retainedVariants": "Lobby and planet GUI/Menu classes assembled without unrelated archive changes; method-level audit excludes only explicit target methods."
|
||||
}
|
||||
}
|
||||
|
|
@ -112,12 +112,14 @@ public final class DuneMenusPlugin extends JavaPlugin implements TabExecutor {
|
|||
|
||||
public void openMenu(Player player, String menu) {
|
||||
if (player.hasPermission("dunemenus.use")) create(menu, player, null).open();
|
||||
else player.sendMessage("You do not have permission to open this menu.");
|
||||
}
|
||||
|
||||
public void presentService(Player player, String section, String title, String description,
|
||||
org.bukkit.inventory.Inventory inventory, Map<Integer, Runnable> actions) {
|
||||
if (player.hasPermission("dunemenus.use"))
|
||||
new ServiceMenu(this, player, section, title, description, inventory, actions).open();
|
||||
else player.sendMessage("You do not have permission to open this menu.");
|
||||
}
|
||||
|
||||
void organisationServices(Player player,String kind,String id) {
|
||||
|
|
@ -229,7 +231,7 @@ public final class DuneMenusPlugin extends JavaPlugin implements TabExecutor {
|
|||
@Override
|
||||
public List<String> onTabComplete(CommandSender s, Command c, String l, String[] a) {
|
||||
if (a.length != 1) return List.of();
|
||||
return java.util.stream.Stream.concat(IDS.stream(), java.util.stream.Stream.of("reload"))
|
||||
return java.util.stream.Stream.concat(IDS.stream(), java.util.stream.Stream.of("reload", "cookbook"))
|
||||
.filter(x -> x.startsWith(a[0].toLowerCase())).toList();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
38
DuneMenus/src/main/java/com/dunerealms/menus/MenuPolish.java
Normal file
38
DuneMenus/src/main/java/com/dunerealms/menus/MenuPolish.java
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
package com.dunerealms.menus;
|
||||
|
||||
/** Presentation only: original slot identifiers and callbacks remain unchanged. */
|
||||
final class MenuPolish {
|
||||
private MenuPolish() {}
|
||||
static String apply(String html) {
|
||||
if (html.contains("/* compact-dune-cards */")) return html;
|
||||
return html.replace("</style>", "/* compact-dune-cards */" + CSS + "</style>");
|
||||
}
|
||||
private static final String CSS = """
|
||||
|
||||
/* Compact service cards: 75% of their previous dimensions; retain the Dune palette. */
|
||||
.card{width:13.875%;height:103.5px;padding:5px;border-radius:8px;box-shadow:inset 0 0 0 1px #0a231f,0 2px 6px #071713}
|
||||
.card:hover{box-shadow:inset 0 0 0 1px #0a231f,0 2px 8px #071713}
|
||||
.hub .card{width:13.875%;min-height:66.75px}.journal .card{width:23.25%;height:103.5px;min-height:51px;padding:6px}
|
||||
.council .card{width:25.875%;height:103.5px;min-height:86.25px}.bank .card{width:18%;min-height:75px}
|
||||
.card .emblem{font-size:19.5px;width:24px;height:24px;line-height:20px;padding:1px;margin:0 auto 2px;border-radius:6px;box-shadow:none;text-shadow:none}
|
||||
.card .item-icon{width:20px;height:20px}.card h2{font-size:11.5px;line-height:1.15;height:26.45px;overflow:hidden;margin:0 0 2px}.card p{font-size:9.5px;line-height:1.2;max-height:22.8px;overflow:hidden;margin:1px 0}.card p+p{max-height:11.4px}.house-choices .card p{max-height:11.4px}.locked.card{height:auto;min-height:103.5px}.locked.card p{max-height:none}
|
||||
.house-choices .card{width:19.5%;height:78.75px;min-height:78.75px}.house-choices .card h2{font-size:11px}
|
||||
.house-choices .card .emblem{font-size:19.5px;width:24px;height:24px;line-height:20px}.house-choices .card .item-icon{width:20px;height:20px}
|
||||
.constellation{height:auto;min-height:262.5px;display:flex;flex-wrap:wrap;gap:12px;justify-content:center;align-items:flex-start;align-content:flex-start;padding:12px 0 36px}
|
||||
.constellation .card{position:relative;top:auto;left:auto;right:auto;width:129.75px;height:54px;min-height:54px;padding:6px;border-radius:8px}
|
||||
.constellation .locked.card{height:auto;min-height:63px}.constellation .back{position:absolute;bottom:0;left:0}
|
||||
.detail-link{right:4px;top:4px;font-size:8px;padding:1px 3px;border-radius:5px}
|
||||
.goods{width:75%;margin:0 auto;gap:12px}.travel .goods{gap:18px}.community .goods{gap:15px}.quest .goods{gap:7.5px}.hub .goods{max-width:637.5px;width:75%}
|
||||
.slot{min-height:93px;padding:8.25px 5px 7.5px;border-width:2px;border-radius:8px;box-shadow:inset 0 0 0 1px #081d1b,0 2px 5px #091d17}
|
||||
.slot:hover,.slot.selected{box-shadow:inset 0 0 0 1px #081d1b,0 2px 7px #091d17}
|
||||
.hub .slot{min-height:99px}.slot strong,.hub .slot strong{font-size:12px;line-height:1.2;overflow-wrap:break-word}
|
||||
.slot .cubby,.travel .cubby{width:36px;height:36px;border-radius:7px}.slot .cubby img{width:30px;height:30px}
|
||||
.travel .slot{min-height:108.75px}.quest .slot{min-height:57.75px;padding:5px 11.25px;grid-template-columns:42.75px 1fr;column-gap:9.75px}
|
||||
.quest .slot strong{font-size:15px}.quest .slot .cubby{width:36px;height:36px}.slot .tag{font-size:10px;margin-top:4.5px}.slot .cubby{margin-bottom:5.25px}.quest .slot .cubby{margin:0}
|
||||
.mission{width:72%;min-height:27px;padding:5px 11px;font-size:12px;border-width:1px;border-radius:6px}
|
||||
.mission span{font-size:11px}.primary{width:60%;min-height:32.25px;padding:5px 11px;font-size:15px;border-width:1px;border-radius:6px}
|
||||
.secondary{width:54%;min-height:24.75px;padding:4.5px 11px;font-size:11.25px;border-width:1px;border-radius:6px}
|
||||
.slots{width:75%;margin:0 auto;gap:5.25px}.member{min-height:35.25px;border-radius:6px;font-size:11px}.member .number{width:17.25px;padding:4.5px 0;font-size:9px}
|
||||
@media(max-width:600px){.goods,.hub .goods{width:100%}.slot strong,.hub .slot strong{font-size:12px}}
|
||||
""";
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -27,7 +27,26 @@ public class RendererVerification {
|
|||
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);
|
||||
if(!page.problems.isEmpty())throw new AssertionError(id+" parser problems "+page.problems);
|
||||
int marker=html.indexOf("/* compact-dune-cards */"),styleEnd=html.indexOf("</style>",marker);
|
||||
String baseline=html.substring(0,marker)+html.substring(styleEnd);
|
||||
var oldPage=Page.of(baseline,dir.resolve(id+"-before.html"),loader);
|
||||
var oldFrame=HtmlRenderer.render(oldPage,1536,896,1.5,0,Selector.State.NONE);
|
||||
var oldBox=oldFrame.boundsOf(oldPage.document.selectFirst("main .card"));
|
||||
var newBox=frame.boundsOf(page.document.selectFirst("main .card"));
|
||||
if(Math.abs(newBox.getWidth()/oldBox.getWidth()-.75)>.002 || Math.abs(newBox.getHeight()/oldBox.getHeight()-.75)>.002)
|
||||
throw new AssertionError(id+" card size must be 75%: "+oldBox+" -> "+newBox);
|
||||
|
||||
ImageIO.write(frame.image(),"png",dir.resolve(id+"-matrix-engine.png").toFile());
|
||||
int styleClose=html.indexOf("</style>");
|
||||
String withoutTextClipping=html.substring(0,styleClose)+".card p,.card p+p,.house-choices .card p{max-height:none;overflow:visible}"+html.substring(styleClose);
|
||||
var fullPage=Page.of(withoutTextClipping,dir.resolve(id+"-full-money.html"),loader);
|
||||
var fullFrame=HtmlRenderer.render(fullPage,1536,896,1.5,0,Selector.State.NONE);
|
||||
var displayed=page.document.select("main .card p");var complete=fullPage.document.select("main .card p");
|
||||
for(int n=0;n<displayed.size();n++)if(displayed.get(n).text().contains("DM")){
|
||||
var visibleBox=frame.boundsOf(displayed.get(n));var naturalBox=fullFrame.boundsOf(complete.get(n));
|
||||
if(visibleBox.getHeight()+.1<naturalBox.getHeight())throw new AssertionError(id+" clipped monetary text: "+displayed.get(n).text());
|
||||
}
|
||||
|
||||
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());
|
||||
|
|
@ -40,6 +59,13 @@ 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));
|
||||
}
|
||||
String readOnlyHtml=SuppliedDocument.html("hub","Status","",List.of(new Card(13,"Account status",List.of("Read only"),"paper",false)),List.of());
|
||||
var readOnlyPage=Page.of(readOnlyHtml,dir.resolve("read-only.html"),loader);var readOnlyFrame=HtmlRenderer.render(readOnlyPage,1536,896,1.5,0,Selector.State.NONE);
|
||||
int readOnlyMarker=readOnlyHtml.indexOf("/* compact-dune-cards */"),readOnlyEnd=readOnlyHtml.indexOf("</style>",readOnlyMarker);
|
||||
var readOnlyBefore=Page.of(readOnlyHtml.substring(0,readOnlyMarker)+readOnlyHtml.substring(readOnlyEnd),dir.resolve("read-only-before.html"),loader);
|
||||
var readOnlyOldFrame=HtmlRenderer.render(readOnlyBefore,1536,896,1.5,0,Selector.State.NONE);
|
||||
var readOnlyBox=readOnlyFrame.boundsOf(readOnlyPage.document.selectFirst("main .card"));var readOnlyOldBox=readOnlyOldFrame.boundsOf(readOnlyBefore.document.selectFirst("main .card"));
|
||||
if(Math.abs(readOnlyBox.getHeight()/readOnlyOldBox.getHeight()-.75)>.002 || !readOnlyPage.document.select("main [data-slot]").isEmpty())throw new AssertionError("Read-only card sizing or authority changed");
|
||||
verifyNavigators(dir,loader);
|
||||
verifyHouseChoices(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);
|
||||
|
|
@ -78,9 +104,10 @@ public class RendererVerification {
|
|||
throw new AssertionError("House text outside card: "+bounds+" vs "+box);
|
||||
}
|
||||
}
|
||||
if(onFirstRow!=3)throw new AssertionError("Expected three House cards across, got "+onFirstRow);
|
||||
int expectedColumns=page.document.selectFirst("main").hasClass("house-choices")?4:3;
|
||||
if(onFirstRow!=expectedColumns)throw new AssertionError("Expected "+expectedColumns+" compact House cards across, got "+onFirstRow);
|
||||
ImageIO.write(frame.image(),"png",dir.resolve("house-choices-engine.png").toFile());
|
||||
System.out.println("House selector: five original actions, three columns, contained text");
|
||||
System.out.println("House selector: five original actions, variant-preserving compact columns, contained text");
|
||||
}
|
||||
|
||||
private static void verifyNavigators(Path dir,Page.Loader loader)throws Exception{
|
||||
|
|
|
|||
|
|
@ -74,6 +74,12 @@ public final class DuneCore extends JavaPlugin implements Listener, CommandExecu
|
|||
sharedDatabase.transaction(player, selected, operation);
|
||||
}
|
||||
|
||||
public UUID freezeBuilderProfile(Player player) throws Exception {
|
||||
if (sharedDatabase == null) throw new java.sql.SQLException("Shared profile unavailable");
|
||||
restoreOrdosArmor(player.getUniqueId());
|
||||
return sharedDatabase.freezeBuilderProfile(player, selected);
|
||||
}
|
||||
|
||||
public Politics politics(){return politics;}
|
||||
public String factionOf(Player player){return selected.getOrDefault(player.getUniqueId(),"");}
|
||||
public void persistPlayers(){savePlayers();}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ public final class SharedDatabase implements AutoCloseable {
|
|||
private final String url, user, password;
|
||||
// Main-thread only. A dedicated connection owns the advisory lock until quit.
|
||||
private final Map<UUID, Connection> sessions = new HashMap<>();
|
||||
private record BuilderLease(UUID token, Connection connection) {}
|
||||
private final Map<UUID, BuilderLease> builderLeases = new HashMap<>();
|
||||
|
||||
public SharedDatabase(JavaPlugin plugin) throws SQLException {
|
||||
this.plugin = plugin;
|
||||
|
|
@ -128,6 +130,89 @@ public final class SharedDatabase implements AutoCloseable {
|
|||
}
|
||||
}
|
||||
|
||||
/** Durably checkpoint the survival profile before any Builder inventory changes. */
|
||||
public UUID freezeBuilderProfile(Player player, Map<UUID, String> factions) throws Exception {
|
||||
UUID id = player.getUniqueId();
|
||||
Connection connection = sessions.get(id);
|
||||
if (connection == null || connection.isClosed() || !connection.getAutoCommit() || builderLeases.containsKey(id)) {
|
||||
throw new SQLException("An owned, unfrozen shared profile is required");
|
||||
}
|
||||
player.closeInventory();
|
||||
writePlayer(player, factions, false);
|
||||
UUID token = UUID.randomUUID();
|
||||
builderLeases.put(id, new BuilderLease(token, connection));
|
||||
return token;
|
||||
}
|
||||
|
||||
/** Read the committed survival checkpoint using the same profile-owning connection. */
|
||||
public void thawBuilderProfile(Player player, UUID token) throws Exception {
|
||||
UUID id = player.getUniqueId();
|
||||
BuilderLease lease = builderLeases.get(id);
|
||||
Connection connection = sessions.get(id);
|
||||
if (lease == null || !lease.token().equals(token) || lease.connection() != connection
|
||||
|| connection.isClosed() || !connection.getAutoCommit()) {
|
||||
throw new SQLException("The Builder checkpoint no longer belongs to this session");
|
||||
}
|
||||
ItemStack[] inventory;
|
||||
int level, total, slot;
|
||||
float progress;
|
||||
try (PreparedStatement query = connection.prepareStatement(
|
||||
"SELECT inventory,experience_level,experience_progress,total_experience,held_slot FROM dune_players WHERE uuid=? AND session_open=TRUE")) {
|
||||
bindBuilderUuid(query, connection, id);
|
||||
try (ResultSet row = query.executeQuery()) {
|
||||
if (!row.next()) throw new SQLException("Committed Builder checkpoint is missing");
|
||||
inventory = decode(row.getString("inventory"));
|
||||
level = row.getInt("experience_level");
|
||||
progress = row.getFloat("experience_progress");
|
||||
total = row.getInt("total_experience");
|
||||
slot = row.getInt("held_slot");
|
||||
}
|
||||
}
|
||||
if (inventory.length != player.getInventory().getContents().length || level < 0 || total < 0
|
||||
|| !Float.isFinite(progress) || progress < 0 || progress >= 1 || slot < 0 || slot > 8) {
|
||||
throw new IOException("Invalid committed Builder checkpoint");
|
||||
}
|
||||
player.getInventory().setContents(inventory);
|
||||
player.setLevel(level);
|
||||
player.setExp(progress);
|
||||
player.setTotalExperience(total);
|
||||
player.getInventory().setHeldItemSlot(slot);
|
||||
builderLeases.remove(id);
|
||||
}
|
||||
|
||||
private static void bindBuilderUuid(PreparedStatement query, Connection connection, UUID id) throws SQLException {
|
||||
if (connection.getMetaData().getDatabaseProductName().equalsIgnoreCase("PostgreSQL")) query.setObject(1, id);
|
||||
else query.setString(1, id.toString());
|
||||
}
|
||||
|
||||
private boolean preserveFrozenBuilderProfile(Player player, Connection connection, boolean release) throws SQLException {
|
||||
UUID id = player.getUniqueId();
|
||||
BuilderLease lease = builderLeases.get(id);
|
||||
if (lease == null) return false;
|
||||
if (lease.connection() != connection || connection.isClosed() || !connection.getAutoCommit()) {
|
||||
throw new SQLException("The Builder profile connection is no longer owned");
|
||||
}
|
||||
if (release) {
|
||||
// The survival checkpoint is already durable. Never serialize creative inventory on quit.
|
||||
try (PreparedStatement query = connection.prepareStatement(
|
||||
"UPDATE dune_players SET session_open=FALSE WHERE uuid=? AND session_open=TRUE")) {
|
||||
bindBuilderUuid(query, connection, id);
|
||||
if (query.executeUpdate() != 1) throw new SQLException("Could not close the Builder profile checkpoint");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void requireUnfrozenBuilderProfile(Player player) throws SQLException {
|
||||
if (builderLeases.containsKey(player.getUniqueId())) {
|
||||
throw new SQLException("Inventory transactions are unavailable in Builder");
|
||||
}
|
||||
}
|
||||
|
||||
private void forgetBuilderProfile(Player player) {
|
||||
builderLeases.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
public void savePlayer(Player p, Map<UUID, String> factions) throws Exception {
|
||||
writePlayer(p, factions, false);
|
||||
}
|
||||
|
|
@ -139,6 +224,7 @@ public final class SharedDatabase implements AutoCloseable {
|
|||
p.closeInventory(); // Return cursor and crafting items before the final snapshot.
|
||||
writePlayer(p, factions, true);
|
||||
} finally {
|
||||
forgetBuilderProfile(p);
|
||||
Connection c = sessions.remove(p.getUniqueId());
|
||||
if (c != null) c.close();
|
||||
}
|
||||
|
|
@ -146,7 +232,7 @@ public final class SharedDatabase implements AutoCloseable {
|
|||
|
||||
private void writePlayer(Player p, Map<UUID, String> factions, boolean release) throws Exception {
|
||||
Connection c = sessions.get(p.getUniqueId());
|
||||
if (c == null) return;
|
||||
if (c == null || preserveFrozenBuilderProfile(p, c, release)) return;
|
||||
// Never reconnect here: a replacement connection would not own the session lock.
|
||||
String inventory = encode(p.getInventory().getContents());
|
||||
try (PreparedStatement q = c.prepareStatement(
|
||||
|
|
@ -184,6 +270,7 @@ public final class SharedDatabase implements AutoCloseable {
|
|||
public void transaction(Player p, Map<UUID, String> factions, java.util.function.Consumer<Connection> operation) throws Exception {
|
||||
Connection c = sessions.get(p.getUniqueId());
|
||||
if (c == null) throw new SQLException("A loaded shared network profile is required to trade");
|
||||
requireUnfrozenBuilderProfile(p);
|
||||
ItemStack[] before = Arrays.stream(p.getInventory().getContents())
|
||||
.map(item -> item == null ? null : item.clone()).toArray(ItemStack[]::new);
|
||||
int priorLevel=p.getLevel(),priorTotal=p.getTotalExperience();float priorProgress=p.getExp();
|
||||
|
|
@ -221,6 +308,7 @@ public final class SharedDatabase implements AutoCloseable {
|
|||
for (Connection c : sessions.values()) try { c.close(); }
|
||||
catch (SQLException ex) { plugin.getLogger().warning("Profile connection close failed: " + ex.getMessage()); }
|
||||
sessions.clear();
|
||||
builderLeases.clear();
|
||||
}
|
||||
|
||||
public String loadPolitics() throws SQLException {
|
||||
|
|
|
|||
|
|
@ -79,6 +79,47 @@ class SharedDatabaseTest {
|
|||
DriverManager.deregisterDriver(driver);
|
||||
}
|
||||
|
||||
@Test void builderCheckpointRejectsCreativeWritesAndRestoresCommittedInventory() throws Exception {
|
||||
db.loadPlayer(player, factions);
|
||||
when(owner.getAutoCommit()).thenReturn(true);
|
||||
var meta = mock(DatabaseMetaData.class);
|
||||
when(meta.getDatabaseProductName()).thenReturn("PostgreSQL");
|
||||
when(owner.getMetaData()).thenReturn(meta);
|
||||
var encoded = org.mockito.ArgumentCaptor.forClass(String.class);
|
||||
UUID token = db.freezeBuilderProfile(player, factions);
|
||||
assertNotNull(token);
|
||||
verify(update, atLeastOnce()).setString(eq(2), encoded.capture());
|
||||
var checkpoint = encoded.getValue();
|
||||
assertNotNull(checkpoint);
|
||||
clearInvocations(update, inventory);
|
||||
db.savePlayer(player, factions);
|
||||
assertThrows(SQLException.class, () -> db.transaction(player, Map.of(), connection -> fail("creative transaction ran")));
|
||||
assertThrows(SQLException.class, () -> db.thawBuilderProfile(player, UUID.randomUUID()));
|
||||
verifyNoInteractions(update, inventory);
|
||||
when(update.executeQuery()).thenReturn(profile);
|
||||
when(profile.getString("inventory")).thenReturn(checkpoint);
|
||||
db.thawBuilderProfile(player, token);
|
||||
verify(inventory).setContents(any(ItemStack[].class));
|
||||
db.savePlayer(player, factions);
|
||||
verify(update).setString(eq(2), anyString());
|
||||
}
|
||||
|
||||
@Test void quittingBuilderClosesOnlyTheDurableMarker() throws Exception {
|
||||
db.loadPlayer(player, factions);
|
||||
when(owner.getAutoCommit()).thenReturn(true);
|
||||
var meta = mock(DatabaseMetaData.class);
|
||||
when(meta.getDatabaseProductName()).thenReturn("PostgreSQL");
|
||||
when(owner.getMetaData()).thenReturn(meta);
|
||||
db.freezeBuilderProfile(player, factions);
|
||||
clearInvocations(owner, update, inventory);
|
||||
db.releasePlayer(player, factions);
|
||||
verify(owner).prepareStatement("UPDATE dune_players SET session_open=FALSE WHERE uuid=? AND session_open=TRUE");
|
||||
verify(update).setObject(1, id);
|
||||
verify(update, never()).setString(eq(2), anyString());
|
||||
verifyNoInteractions(inventory);
|
||||
assertFalse(db.isLoaded(id));
|
||||
}
|
||||
|
||||
@Test void failedLockNeverLoadsOrSavesLocalItems() throws Exception {
|
||||
when(lockResult.getBoolean(1)).thenReturn(false);
|
||||
assertThrows(SQLException.class, () -> db.loadPlayer(player, factions));
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import java.security.MessageDigest
|
||||
plugins { java }
|
||||
group = "com.dunerealms"
|
||||
version = "1.1.41-house1"
|
||||
|
|
@ -18,3 +19,28 @@ sourceSets.main { java.srcDirs("../citizens-common/src/main/java", "../pack-sess
|
|||
tasks.processResources {
|
||||
from(rootProject.file("../network/content-assets/cookbook/spice-crafting.json"))
|
||||
}
|
||||
|
||||
val mcguiRuntime = providers.gradleProperty("mcguiRuntime")
|
||||
val rendererRuntimeFiles = mcguiRuntime.map { files(it) }.getOrElse(files())
|
||||
val rendererTest by sourceSets.creating {
|
||||
compileClasspath += sourceSets.main.get().output + rendererRuntimeFiles
|
||||
runtimeClasspath += sourceSets.main.get().output + rendererRuntimeFiles
|
||||
}
|
||||
val verifyRendererRuntime by tasks.registering {
|
||||
doLast {
|
||||
require(mcguiRuntime.isPresent) { "Supply -PmcguiRuntime=<existing MCGUI-0.8.6.jar>" }
|
||||
val jar = file(mcguiRuntime.get())
|
||||
require(jar.isFile) { "MCGUI runtime file not found" }
|
||||
val hash = MessageDigest.getInstance("SHA-256").digest(jar.readBytes()).joinToString("") { "%02x".format(it) }
|
||||
require(hash == "69a454291cc27c36cdbc680bfbde245a90a3913de53cc1591c502a5a49124300") { "MCGUI runtime differs from reviewed test input" }
|
||||
logger.lifecycle("Renderer verification: MCGUI0.8.6 SHA-256 {}", hash)
|
||||
}
|
||||
}
|
||||
tasks.named(rendererTest.compileJavaTaskName) { dependsOn(verifyRendererRuntime) }
|
||||
tasks.register<JavaExec>("verifyMenuRenderer") {
|
||||
dependsOn(rendererTest.classesTaskName)
|
||||
classpath = rendererTest.runtimeClasspath
|
||||
mainClass.set("com.dunerealms.gui.CompactRendererVerification")
|
||||
jvmArgs("-Djava.awt.headless=true")
|
||||
args(providers.gradleProperty("rendererOutput").getOrElse(layout.buildDirectory.dir("renderer-verification").get().asFile.absolutePath))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,6 +148,7 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
|
|||
panel.inventory=Bukkit.createInventory(panel,54,Component.text(title,NamedTextColor.GOLD));
|
||||
panel.inventory.setItem(22,icon(player,"Return to Guild Lobby",detail,"drgui_transparent",Material.COMPASS));
|
||||
panel.actions.put(22,returnToLobby);
|
||||
button(panel,player,45,"Back","Imperial Codex",Material.ARROW,()->organisations.console(player));
|
||||
if(MCGUIMenus.show(player,title,detail,panel.inventory,panel.actions,panel.gate))return;
|
||||
player.openInventory(panel.inventory);
|
||||
expire(panel);
|
||||
|
|
|
|||
|
|
@ -50,13 +50,13 @@ final class MenuDocument {
|
|||
String image=icon(c,root);b.append("<button ").append(c.action?"data-slot":"data-pick").append("=\"").append(c.slot).append("\" class=\"slot ").append(c==detail?"selected":"").append(c.material.equals("light_blue_dye")?" ingame":"").append("\"><span class=\"cubby\">");if(!image.isBlank())b.append("<img src=\"").append(image).append("\">");else b.append("<span class=\"sigil\">◇</span>");
|
||||
b.append("</span><strong>").append(escape(c.title)).append("</strong><span class=\"tag\">").append(escape(fact(c))).append("</span></button>");
|
||||
}b.append("</div>");
|
||||
b.append("</section></main><footer><span>J.A.R.V.I.S. · Your realm, connected</span><span>Click an action · Scroll for more · Sneak to close</span></footer></body></html>");return b.toString();
|
||||
b.append("</section></main><footer><span>J.A.R.V.I.S. · Your realm, connected</span><span>Click an action · Scroll for more · Sneak to close</span></footer></body></html>");return MenuPolish.apply(b.toString());
|
||||
}
|
||||
static String warMusterRoom(String description,String player,List<Card> cards,Path root){
|
||||
Map<Integer,Card> positions=new HashMap<>();for(Card card:cards)positions.put(card.slot,card);Card own=cards.stream().filter(c->c.lore.stream().anyMatch(l->l.equals("Your team"))).findFirst().orElse(null);String side=own!=null&&own.title.startsWith("Red")?"red":"blue";
|
||||
StringBuilder b=new StringBuilder("<!doctype html><html><head><meta charset=\"utf-8\"><style>").append(WAR_CSS).append("</style></head><body><div class=\"war-frame\"><header><img src=\"art/logo.png\"><div><small>J.A.R.V.I.S. · CLAN WAR</small><h1>WAR MUSTER ROOM</h1></div><span>").append(escape(player)).append("</span><button class=\"close\" data-slot=\"-1\">×</button></header><p class=\"brief\">").append(escape(description).replace("\n"," · ")).append("</p><main><section class=\"roster ").append(side).append("\"><h2>").append(escape(own==null?"YOUR TEAM":own.title)).append("</h2><div class=\"slots\">");
|
||||
int[] slots={19,20,21,22,28,29,30,31};for(int i=0;i<slots.length;i++){Card card=positions.get(slots[i]);if(card==null)continue;String tag=card.action?"button":"div";b.append('<').append(tag).append(" class=\"member ").append(card.title.startsWith("Empty slot")?"empty":"").append("\"");if(card.action)b.append(" data-slot=\"").append(card.slot).append("\"");b.append("><span class=\"number\">").append(i+1).append("</span><span class=\"name\">").append(escape(card.title)).append("</span><span class=\"select\">").append(card.action?"▾":"◇").append("</span></").append(tag).append('>');}b.append("</div></section><section class=\"status\"><h2>PROVINCE & ROSTER STATUS</h2><div class=\"provinces\">");
|
||||
for(int slot:new int[]{2,6}){Card c=positions.get(slot);if(c==null)continue;String color=c.title.startsWith("Red")?"red":"blue";b.append("<article class=\"province ").append(color).append("\"><span class=\"flag\">⚑</span><strong>").append(escape(c.title)).append("</strong>");for(String lore:c.lore)b.append("<p>").append(escape(lore)).append("</p>");b.append("</article>");}b.append("</div>");Card key=positions.get(34);if(key!=null){b.append("<div class=\"key\"><h3>TEAM ROSTER KEY</h3>");for(String line:key.lore)b.append("<p>").append(escape(line)).append("</p>");b.append("</div>");}b.append("</section></main><footer>");for(int slot:new int[]{45,47,49,51}){Card c=positions.get(slot);if(c==null)continue;b.append("<button class=\"").append(slot==49?"save ":slot==51?"launch ":"").append(c.action?"":"disabled").append("\"");if(c.action)b.append(" data-slot=\"").append(c.slot).append("\"");b.append('>').append(escape(c.title)).append("</button>");}b.append("</footer><p class=\"notice\">Auto-launch 15 minutes after scheduled start · Sneak to close</p></div></body></html>");return b.toString();
|
||||
for(int slot:new int[]{2,6}){Card c=positions.get(slot);if(c==null)continue;String color=c.title.startsWith("Red")?"red":"blue";b.append("<article class=\"province ").append(color).append("\"><span class=\"flag\">⚑</span><strong>").append(escape(c.title)).append("</strong>");for(String lore:c.lore)b.append("<p>").append(escape(lore)).append("</p>");b.append("</article>");}b.append("</div>");Card key=positions.get(34);if(key!=null){b.append("<div class=\"key\"><h3>TEAM ROSTER KEY</h3>");for(String line:key.lore)b.append("<p>").append(escape(line)).append("</p>");b.append("</div>");}b.append("</section></main><footer>");for(int slot:new int[]{45,47,49,51}){Card c=positions.get(slot);if(c==null)continue;b.append("<button class=\"").append(slot==49?"save ":slot==51?"launch ":"").append(c.action?"":"disabled").append("\"");if(c.action)b.append(" data-slot=\"").append(c.slot).append("\"");b.append('>').append(escape(c.title)).append("</button>");}b.append("</footer><p class=\"notice\">Auto-launch 15 minutes after scheduled start · Sneak to close</p></div></body></html>");return MenuPolish.apply(b.toString());
|
||||
}
|
||||
private static final String WAR_CSS="""
|
||||
*{box-sizing:border-box}body{margin:0;padding:14px;background:linear-gradient(145deg,#142f25,#081e19);color:#f5e7bd;font-family:Minecraft,monospace;font-size:13px}.war-frame{border:3px solid #d3a84c;border-radius:12px;padding:12px 18px 9px;background:linear-gradient(150deg,#244735,#10291f);box-shadow:inset 0 0 0 2px #604d22,0 8px 22px #0009}header{display:flex;align-items:center;gap:16px;height:62px;border-bottom:2px solid #bf9746;padding-bottom:5px}header img{width:150px;height:54px;object-fit:contain}header div{flex:1}header small{color:#c9a958;font-size:10px;letter-spacing:2px}h1{margin:3px 0;font-size:24px;color:#f2d58b}header span{color:#c8d8be;font-size:10px}.close{width:33px;height:32px}.brief{font-size:10px;color:#e6ca85;line-height:1.4;margin:7px 0 10px}main{display:grid;grid-template-columns:1fr 1fr;gap:14px}.roster,.status{border:2px solid #c49c40;border-radius:7px;padding:8px;background:#0b221b}h2{font-size:15px;letter-spacing:1px;margin:0 0 7px;padding:6px;text-align:center;color:#fff0c6;border-bottom:1px solid #bc9848}.roster.blue h2{background:#234e82}.roster.red h2{background:#713a36}.slots{display:grid;grid-template-columns:1fr 1fr;gap:7px}.member{display:flex;align-items:center;gap:7px;min-height:47px;padding:4px;border:1px solid #c5a259;border-radius:4px;background:linear-gradient(90deg,#193d2c,#123025);color:#efdfb5;text-align:left;font:12px Minecraft,monospace}.member:hover{background:#42664c}.number{background:#24485f;border:1px solid #c6a253;border-radius:3px;width:23px;text-align:center;padding:6px 0}.red .number{background:#7c3535}.name{flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.member.empty{color:#9bafaa}.select{color:#dfb85f}.provinces{display:grid;grid-template-columns:1fr 1fr;gap:7px}.province{padding:8px;border:1px solid #c5a259;border-radius:5px;background:#213e35;min-height:105px}.province.blue{background:linear-gradient(145deg,#25567c,#162f43)}.province.red{background:linear-gradient(145deg,#884846,#442c2b)}.province strong{font-size:12px;color:#ffe7a1;display:block;margin-bottom:4px}.flag{float:right;color:#e2bd62;font-size:24px}.province p,.key p{font-size:10px;margin:3px 0;color:#e5dbc1;line-height:1.4}.key{margin-top:9px;border:1px solid #bb9144;padding:7px;border-radius:4px;background:#132f24}.key h3{margin:0 0 4px;font-size:12px;color:#f3cf7b}.key p:first-of-type{font-size:14px;color:#fff0b4;overflow-wrap:break-word}footer{display:flex;gap:10px;justify-content:center;margin-top:10px}button{font:12px Minecraft,monospace;padding:9px 14px;color:#fbe5aa;border:2px solid #c7a353;background:#183b2b;border-radius:5px}button[data-slot]:hover{background:#42664c}.save{background:linear-gradient(140deg,#f2d18b,#b58a39);color:#28230c;min-width:150px}.launch{min-width:145px;background:#543e20}.disabled{background:#394744;color:#a6b1ab;border-color:#65736b}.notice{text-align:center;color:#c8b77b;font-size:10px;margin:6px 0 0}
|
||||
|
|
@ -73,7 +73,7 @@ final class MenuDocument {
|
|||
if(dashboard&&pick!=null)b.append("<button class=\"primary\" data-slot=\"").append(pick.slot).append("\">SELECT ").append(decision?"DECISION":"MISSION").append("</button>");
|
||||
if(dashboard&&pick==null&&cards.stream().anyMatch(c->c.action&&c.slot>=9&&c.slot<45))b.append("<p class=\"hint\">Select an entry to continue.</p>");
|
||||
for(Card c:cards){if(!c.action||dashboard&&c.slot>=9&&c.slot<45)continue;String action=c.title.equals("Claim verified reward")?"CLAIM & CONTINUE":c.title;boolean primary=c.slot==31||c.title.equals("Accept")||c.title.equals("Confirm and execute");b.append("<button class=\"").append(primary?"primary":"secondary").append("\" data-slot=\"").append(c.slot).append("\">").append(escape(action)).append("</button>");}
|
||||
return b.append("</section><footer>SHIFT TO CLOSE</footer></div></body></html>").toString();
|
||||
return MenuPolish.apply(b.append("</section><footer>SHIFT TO CLOSE</footer></div></body></html>").toString());
|
||||
}
|
||||
private static final String ROLEPLAY_CSS="""
|
||||
*{box-sizing:border-box}body{margin:0;color:#f8edcf;background:#061c13;font-family:'Source Serif 4',Georgia,serif}.frame{position:relative;min-height:597px;width:100%;display:grid;grid-template-columns:30% 70%;background-image:url('art/quest-dialogue-frame.png');background-size:100% 100%;background-repeat:no-repeat;padding:18px 22px 42px}.portrait{position:relative;padding:17px 27px 122px 17px;display:flex;align-items:center;justify-content:center;min-height:500px}.avatar{width:100%;height:auto;max-height:370px;object-fit:contain;image-rendering:pixelated}.nameplate{position:absolute;bottom:10px;left:18px;right:36px;text-align:center}.nameplate h2{font-size:25px;line-height:1.08;margin:0;color:#f6e2a8}.nameplate p{font-style:italic;font-size:14px;color:#e5cb8f;margin:8px 4px}.content{padding:0 40px 30px 33px;min-width:0;text-align:center}header{display:flex;align-items:center;justify-content:center;gap:16px;color:#cfa94c}h1{margin:0 0 7px;color:#fff2cd;font-size:32px;letter-spacing:1px;line-height:1.1}.dialogue-art{width:80%;max-height:140px;object-fit:cover;border:1px solid #b59b58;margin:8px auto}.dialogue{font-size:17px;color:#f2dfb1;font-style:italic;margin:7px auto 12px;line-height:1.3;max-width:95%}.summary,.record{border:2px solid #bc9f52;border-radius:6px;padding:8px 14px;margin:9px auto;background:#05251bd9;max-width:96%}.bar{height:15px;border:1px solid #d9ba68;background:#09291d;margin:5px 20px}.bar div{height:100%;background:linear-gradient(#ffe17c,#c69a32)}.summary p,.record p{margin:4px 0;line-height:1.25;font-size:14px}.record h3{margin:2px 0 6px;font-size:20px;color:#f1d293}.paths{color:#f5e0a5;font-size:20px;letter-spacing:1px;margin:12px 0 6px}.mission,.primary,.secondary{background:linear-gradient(#113a29,#08281d);border:2px solid #c0a150;color:#f9ecc6;min-height:36px;padding:7px 15px;border-radius:7px;font:600 16px 'Source Serif 4',Georgia,serif;display:block;width:96%;margin:7px auto;box-shadow:inset 0 1px 0 #f5e0a450}.mission{text-align:left;display:flex;justify-content:space-between;gap:12px}.mission span{font-size:13px;color:#e8d09b}.mission.selected span{color:#3a2c0b}.mission.selected,.primary{background:linear-gradient(#ffe082,#c99a2d);color:#1b1a0b;border:2px solid #fff1b3;box-shadow:0 0 10px #e0ad4b66,inset 0 1px 0 #fff0b9}.primary{font-size:20px;font-weight:700;width:80%;text-transform:uppercase;min-height:43px}.secondary{width:72%;font-size:15px;min-height:33px}.mission:hover,.secondary:hover{border-color:#fff0b9}.hint{color:#cbb47d;font-style:italic;font-size:13px}footer{position:absolute;bottom:13px;left:32%;right:3%;text-align:center;font-size:13px;letter-spacing:3px;color:#f5dd98;font-weight:700}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
package com.dunerealms.gui;
|
||||
|
||||
/** Presentation only: original slot identifiers and callbacks remain unchanged. */
|
||||
final class MenuPolish {
|
||||
private MenuPolish() {}
|
||||
static String apply(String html) {
|
||||
if (html.contains("/* compact-dune-cards */")) return html;
|
||||
return html.replace("</style>", "/* compact-dune-cards */" + CSS + "</style>");
|
||||
}
|
||||
private static final String CSS = """
|
||||
|
||||
/* Compact service cards: 75% of their previous dimensions; retain the Dune palette. */
|
||||
.card{width:13.875%;height:103.5px;padding:5px;border-radius:8px;box-shadow:inset 0 0 0 1px #0a231f,0 2px 6px #071713}
|
||||
.card:hover{box-shadow:inset 0 0 0 1px #0a231f,0 2px 8px #071713}
|
||||
.hub .card{width:13.875%;min-height:66.75px}.journal .card{width:23.25%;height:103.5px;min-height:51px;padding:6px}
|
||||
.council .card{width:25.875%;height:103.5px;min-height:86.25px}.bank .card{width:18%;min-height:75px}
|
||||
.card .emblem{font-size:19.5px;width:24px;height:24px;line-height:20px;padding:1px;margin:0 auto 2px;border-radius:6px;box-shadow:none;text-shadow:none}
|
||||
.card .item-icon{width:20px;height:20px}.card h2{font-size:11.5px;line-height:1.15;height:26.45px;overflow:hidden;margin:0 0 2px}.card p{font-size:9.5px;line-height:1.2;max-height:22.8px;overflow:hidden;margin:1px 0}.card p+p{max-height:11.4px}.house-choices .card p{max-height:11.4px}.locked.card{height:auto;min-height:103.5px}.locked.card p{max-height:none}
|
||||
.house-choices .card{width:19.5%;height:78.75px;min-height:78.75px}.house-choices .card h2{font-size:11px}
|
||||
.house-choices .card .emblem{font-size:19.5px;width:24px;height:24px;line-height:20px}.house-choices .card .item-icon{width:20px;height:20px}
|
||||
.constellation{height:auto;min-height:262.5px;display:flex;flex-wrap:wrap;gap:12px;justify-content:center;align-items:flex-start;align-content:flex-start;padding:12px 0 36px}
|
||||
.constellation .card{position:relative;top:auto;left:auto;right:auto;width:129.75px;height:54px;min-height:54px;padding:6px;border-radius:8px}
|
||||
.constellation .locked.card{height:auto;min-height:63px}.constellation .back{position:absolute;bottom:0;left:0}
|
||||
.detail-link{right:4px;top:4px;font-size:8px;padding:1px 3px;border-radius:5px}
|
||||
.goods{width:75%;margin:0 auto;gap:12px}.travel .goods{gap:18px}.community .goods{gap:15px}.quest .goods{gap:7.5px}.hub .goods{max-width:637.5px;width:75%}
|
||||
.slot{min-height:93px;padding:8.25px 5px 7.5px;border-width:2px;border-radius:8px;box-shadow:inset 0 0 0 1px #081d1b,0 2px 5px #091d17}
|
||||
.slot:hover,.slot.selected{box-shadow:inset 0 0 0 1px #081d1b,0 2px 7px #091d17}
|
||||
.hub .slot{min-height:99px}.slot strong,.hub .slot strong{font-size:12px;line-height:1.2;overflow-wrap:break-word}
|
||||
.slot .cubby,.travel .cubby{width:36px;height:36px;border-radius:7px}.slot .cubby img{width:30px;height:30px}
|
||||
.travel .slot{min-height:108.75px}.quest .slot{min-height:57.75px;padding:5px 11.25px;grid-template-columns:42.75px 1fr;column-gap:9.75px}
|
||||
.quest .slot strong{font-size:15px}.quest .slot .cubby{width:36px;height:36px}.slot .tag{font-size:10px;margin-top:4.5px}.slot .cubby{margin-bottom:5.25px}.quest .slot .cubby{margin:0}
|
||||
.mission{width:72%;min-height:27px;padding:5px 11px;font-size:12px;border-width:1px;border-radius:6px}
|
||||
.mission span{font-size:11px}.primary{width:60%;min-height:32.25px;padding:5px 11px;font-size:15px;border-width:1px;border-radius:6px}
|
||||
.secondary{width:54%;min-height:24.75px;padding:4.5px 11px;font-size:11.25px;border-width:1px;border-radius:6px}
|
||||
.slots{width:75%;margin:0 auto;gap:5.25px}.member{min-height:35.25px;border-radius:6px;font-size:11px}.member .number{width:17.25px;padding:4.5px 0;font-size:9px}
|
||||
@media(max-width:600px){.goods,.hub .goods{width:100%}.slot strong,.hub .slot strong{font-size:12px}}
|
||||
""";
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ final class QuestMenus implements Listener {
|
|||
if(selected!=null){var row=available.stream().filter(q->selected.equals(text(q,"id",""))).findFirst().orElse(null);if(row!=null){roleSelected(p,data,role,row);return;}}
|
||||
var screen=panel(p,"NPC dashboard · "+role.name());screen.description="";roleAvatar(screen,data,role);int active=0,ready=0,claimed=0;for(var e:data.getAsJsonArray("quests")){var q=e.getAsJsonObject();if(!roleAllowed(data,role,q))continue;if(text(q,"state","").equals("claimed"))claimed++;else if(yes(q,"canClaim"))ready++;else if(text(q,"state","").equals("active"))active++;}String stats=active+" active · "+ready+" ready · "+claimed+" claimed";if(data.has("npcSummary")&&data.get("npcSummary").isJsonObject()){var rep=data.getAsJsonObject("npcSummary");stats+="\nReputation "+text(rep,"xp","—")+" / "+text(rep,"nextXP","—");if(rep.has("percent")&&!rep.get("percent").isJsonNull())stats+="\nProgress: "+Math.max(0,Math.min(100,rep.get("percent").getAsInt()))+"%";}put(screen,5,"Mission overview",stats,Material.PAPER,null);var summary=screen.inventory.getItem(5);var meta=summary.getItemMeta();meta.getPersistentDataContainer().set(new NamespacedKey("dunerealms","menu_art"),org.bukkit.persistence.PersistentDataType.STRING,"npc_summary");summary.setItemMeta(meta);screen.inventory.setItem(5,summary);var ordered=new ArrayList<JsonObject>(available);ordered.sort(Comparator.comparingInt(q->Set.of("active","completed").contains(text(q,"state",""))?0:1));
|
||||
int slot=9;for(var q:ordered){if(slot>=45)break;String status=Set.of("active","completed").contains(text(q,"state",""))?"Progress: "+text(q,"progress","0")+" / "+text(q,"target","1"):"Eligible to accept";put(screen,slot++,text(q,"title","Mission"),status+"\n"+text(q,"id","")+" · "+text(q,"objective",""),Material.WRITABLE_BOOK,()->roleSelected(p,data,role,q));}
|
||||
if(ordered.isEmpty())put(screen,13,"No eligible missions","Read the website journal for the full record.",Material.MAP,null);
|
||||
if(ordered.isEmpty())put(screen,13,"Open your mission journal","No missions are available from this contact right now.\nBrowse your other story arcs and current objectives.",Material.MAP,()->open(p));
|
||||
if(role.key().equals("esmar_tuek")){
|
||||
put(screen,47,"Smuggler Navigator","Review personal passage to another world.",Material.COMPASS,()->smugglerMenu(p,data,role));
|
||||
if(role.world().equals("arrakis"))put(screen,48,"Smuggling contracts","Start a delivery with Esmar Tuek",Material.CHEST,()->p.performCommand("dunenpc smuggle contract"));
|
||||
|
|
|
|||
|
|
@ -8,9 +8,12 @@ final class SuppliedMenus {
|
|||
private SuppliedMenus(){}
|
||||
static boolean open(Player p,String id){return call("openMenu",new Class<?>[]{Player.class,String.class},p,id);}
|
||||
static boolean command(Player p,String command,String[] args){
|
||||
String id=switch(command){case "exchange","spice","clan","company","house","mentat"->command;case "polgui"->"politics";case "warmuster"->"war";case "guildtravel"->args.length==0?"travel":null;case "drgui"->args.length==0?"hub":args.length==1?switch(args[0].toLowerCase(Locale.ROOT)){case "quests"->"missions";case "hub","travel","exchange","clan","company","missions","spice","war","politics","house","equipment","bank","atm","withdraw","lore","mentat"->args[0].toLowerCase(Locale.ROOT);default->null;}:null;default->null;};
|
||||
String id=route(command,args);
|
||||
return id!=null&&open(p,id);
|
||||
}
|
||||
static String route(String command,String[] args){
|
||||
return switch(command){case "exchange","spice","clan","company","house","mentat"->command;case "polgui"->"politics";case "warmuster"->"war";case "guildtravel"->args.length==0?"travel":null;case "drgui"->args.length==0?"hub":args.length==1?switch(args[0].toLowerCase(Locale.ROOT)){case "quests"->"missions";case "hub","travel","exchange","clan","company","missions","spice","war","politics","house","equipment","bank","atm","withdraw","lore","cookbook","mentat"->args[0].toLowerCase(Locale.ROOT);default->null;}:null;default->null;};
|
||||
}
|
||||
static boolean service(Player p,String title,String description,Inventory inventory,Map<Integer,Runnable> actions,GuiSession supplied){
|
||||
GuiSession gate=supplied==null?new GuiSession(p.getUniqueId()):supplied;
|
||||
Map<Integer,Runnable> guarded=new HashMap<>();actions.forEach((slot,action)->guarded.put(slot,()->{if(gate.claim(p.getUniqueId()))action.run();}));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
package com.dunerealms.gui;
|
||||
import java.nio.file.*;import java.util.*;import javax.imageio.ImageIO;
|
||||
import ai.resourcepack.ui.html.*;import ai.resourcepack.ui.html.css.Selector;
|
||||
public class CompactRendererVerification {
|
||||
public static void main(String[] args)throws Exception{
|
||||
Path out=Path.of(args[0]);Files.createDirectories(out);var loader=new Page.Loader(false,out.resolve("cache"));int checked=0;
|
||||
Files.createDirectories(out.resolve("art"));
|
||||
for(Path source:List.of(Path.of("../DuneMenus/src/main/resources/menu-art/art"),Path.of("src/main/resources/mcgui-npc-avatars")))
|
||||
try(var paths=Files.list(source)){for(Path file:paths.filter(Files::isRegularFile).toList())Files.copy(file,out.resolve("art").resolve(file.getFileName()),StandardCopyOption.REPLACE_EXISTING);}
|
||||
var cards=new ArrayList<MenuDocument.Card>();
|
||||
for(int n=0;n<12;n++)cards.add(new MenuDocument.Card(n,"Service "+n,List.of("Authoritative service detail","100.00 DM"),"book",1,true,""));
|
||||
cards.add(new MenuDocument.Card(45,"Back",List.of(),"arrow",1,true,""));
|
||||
for(String title:List.of("Imperial Codex","Equipment","Spacing Guild","Mission journal","Clan","Company","Political offices","Exchange","Rihla ATM","NPC dashboard · Adviser","NPC turn-in · Adviser","War Muster Room")){
|
||||
var rows=cards;
|
||||
if(title.equals("War Muster Room")){
|
||||
rows=new ArrayList<>();rows.add(new MenuDocument.Card(2,"Blue · Own",List.of("Your team"),"blue_banner",1,false,""));
|
||||
rows.add(new MenuDocument.Card(6,"Red · Opponent",List.of("Read only"),"red_banner",1,false,""));
|
||||
for(int slot:new int[]{19,20,21,22,28,29,30,31})rows.add(new MenuDocument.Card(slot,"Member",List.of(),"player_head",1,true,""));
|
||||
for(int slot:new int[]{45,47,49})rows.add(new MenuDocument.Card(slot,"Action",List.of(),"arrow",1,true,""));
|
||||
}
|
||||
String html=MenuDocument.html(title,"Current verified services","Fixture",rows,-1,out);
|
||||
var page=Page.of(html,out.resolve(title.hashCode()+".html"),loader);var frame=HtmlRenderer.render(page,1536,896,1.5,0,Selector.State.NONE);
|
||||
if(!page.problems.isEmpty())throw new AssertionError(title+page.problems.toString());
|
||||
if(page.document.selectFirst(".slot")!=null){
|
||||
int marker=html.indexOf("/* compact-dune-cards */"),end=html.indexOf("</style>",marker);
|
||||
var oldPage=Page.of(html.substring(0,marker)+html.substring(end),out.resolve("before-"+title.hashCode()+".html"),loader);
|
||||
var oldFrame=HtmlRenderer.render(oldPage,1536,896,1.5,0,Selector.State.NONE);
|
||||
var before=oldFrame.boundsOf(oldPage.document.selectFirst(".slot"));var after=frame.boundsOf(page.document.selectFirst(".slot"));
|
||||
if(Math.abs(after.getWidth()/before.getWidth()-.75)>.002 || Math.abs(after.getHeight()/before.getHeight()-.75)>.002)throw new AssertionError(title+" expected 75% card dimensions "+before+" -> "+after);
|
||||
System.out.println(title+" scale width="+after.getWidth()/before.getWidth()+" height="+after.getHeight()/before.getHeight());
|
||||
}
|
||||
var controls=page.document.select("[data-slot],[data-pick]");if(controls.isEmpty())throw new AssertionError(title+" no controls");
|
||||
for(var element:controls){var box=frame.boundsOf(element);if(box==null||box.isEmpty())throw new AssertionError(title+" hidden control");
|
||||
double scroll=Math.max(0,Math.min(frame.maxScroll(),box.getCenterY()-260));
|
||||
var visible=HtmlRenderer.render(page,1536,896,1.5,scroll,Selector.State.NONE);var hit=visible.elementAt(box.getCenterX(),box.getCenterY()-scroll);
|
||||
if(hit==null || hit.closest("[data-slot],[data-pick]")!=element)throw new AssertionError(title+" unreachable "+element+" box="+box);
|
||||
checked++;
|
||||
}
|
||||
ImageIO.write(frame.image(),"png",out.resolve(title.hashCode()+".png").toFile());
|
||||
System.out.println(title+": "+controls.size()+" controls reachable");
|
||||
}
|
||||
System.out.println("PASS "+checked+" native/fallback UI controls");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.dunerealms.gui;
|
||||
import java.util.Set;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
class MenuEntryRoutesTest {
|
||||
@Test void everyCodexServiceHasAnExplicitEntryIncludingCookbook(){
|
||||
for(String id:Set.of("hub","travel","exchange","clan","company","missions","spice","war","politics","house","equipment","bank","atm","withdraw","lore","cookbook","mentat"))
|
||||
assertEquals(id,SuppliedMenus.route("drgui",new String[]{id}),id);
|
||||
assertEquals("missions",SuppliedMenus.route("drgui",new String[]{"quests"}));
|
||||
}
|
||||
@Test void guildEntryDoesNotDependOnAWorldAndTargetedCancellationRemainsNative(){
|
||||
assertEquals("travel",SuppliedMenus.route("guildtravel",new String[]{}));
|
||||
assertNull(SuppliedMenus.route("guildtravel",new String[]{"cancel"}));
|
||||
assertNull(SuppliedMenus.route("drgui",new String[]{"previewitem","id","1"}));
|
||||
assertNull(SuppliedMenus.route("drgui",new String[]{"movenpc","stilgar"}));
|
||||
assertNull(SuppliedMenus.route("drgui",new String[]{"unknown"}));
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue

Staff