Public: anyone can read this; the crew can change it.
Games: installing the quality set ships Essential Commands' config with only /home, /spawn and /tpa on #18199
Merged 4h 34m ago, live in production
torque/forge:torque/18195-games-installing-the-quality-set-ships-e → main 0 commits fork 5 threads · 5 unresolved
5 files
changed +78
−23
docs/features/game-mods.md +1 −1
| @@ -10,7 +10,7 @@ The server's mods or plugins come from Modrinth, for its loader and game version | ||
| 10 | 10 | - **Preview** picks the newest compatible version (a release when there is one) and resolves what it requires, recursively: "Adds Chunky 1.4.28; Adds ChunkyLib 1.0.2 (required by Chunky)". A project with no version for the server, a requirement with none, or two projects that say they are incompatible are refused with the reason. A bare slug already in `MODRINTH_PROJECTS` is pinned by the same change. |
| 11 | 11 | - **Install and restart** is one commit on the commit you previewed: the lockfile `<compose dir>/modrinth/<service>.lock.json` (each project's version id, file path, url and sha512, and whether it was asked for or is a dependency) and the compose env made from it: `MODRINTH_PROJECTS` lists `slug:versionId` for every project and `MODRINTH_DOWNLOAD_DEPENDENCIES=none`, so the image fetches exactly the locked set. A proxy also gets `MINECRAFT_VERSION`, which its Modrinth step needs. On a proxy whose servers sleep, `MODRINTH_PROJECTS` also holds AutoStopper (`PG4gqnzX:EclCtvWk`, see [](games.md)): it is sleep's, so a Modrinth change carries it over as it is and never lists it as the proxy's own, and Warm again takes only that entry. |
| 12 | 12 | - **Sets**: a named set installs in one preview and one commit. `set:survival` is the survival performance set for a Fabric server: Lithium, ScalableLux, Noisium and Chunky, each at its newest release for the server's Minecraft version, with what they require (Chunky needs Fabric API). It adds only what is missing, and a server on another loader is refused with the reason. The web Mods block shows it with a *Preview the set* button until it is installed; the terminal shows the same lines and `s` previews it; MCP `mods_install` takes `project: "set:survival"`. |
| 13 | - **Quality of life**: `set:quality` is graves (Universal Graves), Essential Commands, Styled Chat, Right Click Harvest, Sleep Warp (the night skips while players sleep) and Veinminer (a vein miner) for a Fabric server, installed like the survival set but optional by member: each is resolved alone, and one with no build for the server's Minecraft version (Right Click Harvest on 1.21.6) is left out with the reason ("Left out rightclickharvest: …") while the rest install; if none builds, it is refused. Essential Commands ships every command on; trimming it to /home, /spawn and /tpa is its config, which the owner sets, and the plan says so on a "Before players join" line, on the page and in the terminal. Each set shows a sentence on what it is for, and the web block offers *Preview the Quality of life set*, the terminal's key is `q`, MCP `mods_install` takes `project: "set:quality"`. | |
| 13 | - **Quality of life**: `set:quality` is graves (Universal Graves), Essential Commands, Styled Chat, Right Click Harvest, Sleep Warp (the night skips while players sleep) and Veinminer (a vein miner) for a Fabric server, installed like the survival set but optional by member: each is resolved alone, and one with no build for the server's Minecraft version (Right Click Harvest on 1.21.6) is left out with the reason ("Left out rightclickharvest: …") while the rest install; if none builds, it is refused. Essential Commands is written with its config in the same commit (`config/EssentialCommands.properties`): `enable_home`, `enable_spawn` and `enable_tpa` on, every other `enable_*` off and `use_permissions_api=false`, so every player may use the three with no permission plugin; the plan says so on a "Writes config/…" line, on the page and in the terminal, and nothing is written when Essential Commands is left out or already installed. A key the mod does not read is ignored silently, so on the first start check that `/home` works and `/back` is refused. Removing Essential Commands later leaves its config in the repository. Each set shows a sentence on what it is for, and the web block offers *Preview the Quality of life set*, the terminal's key is `q`, MCP `mods_install` takes `project: "set:quality"`. | |
| 14 | 14 | - **The admin set**, `set:admin`, is LuckPerms (who may run which command) and Ledger (a block log with rollback) for a Fabric server. Ledger needs Fabric Language Kotlin, so the plan adds it as a dependency and the lock holds all three by sha512; removing Ledger takes that dependency with it, which is the way back. Each is the newest release for the server's Minecraft version; where Ledger has none yet the plan is refused with that reason and nothing is written. The web block offers *Preview the Admin set* and the terminal previews it with `r`. |
| 15 | 15 | - **Updates** post the locked sha512s to Modrinth's `/v2/version_files/update` (releases for the loader and version) and show "2 updates" as from → to, one click each or all. |
| 16 | 16 | - **Remove** takes a project and what only it required; a dependency something else requires stays. |
src/games/mod_sets.ts +30 −8
| @@ -22,10 +22,10 @@ export interface ModSet { | ||
| 22 | 22 | */ |
| 23 | 23 | readonly optional?: boolean; |
| 24 | 24 | /** |
| 25 | * What the owner must do about a member before players join, by slug; the plan says it on a line | |
| 26 | * when that member is in it. | |
| 25 | * A config file written in the same commit as a member, by slug (#18195); none when it is left | |
| 26 | * out. | |
| 27 | 27 | */ |
| 28 | readonly cautions?: Readonly<Record<string, string>>; | |
| 28 | readonly configs?: Readonly<Record<string, { readonly file: string; readonly content: string; readonly says: string }>>; | |
| 29 | 29 | /** One line for each project: what it is for. */ |
| 30 | 30 | readonly why: readonly string[]; |
| 31 | 31 | } |
| @@ -48,23 +48,45 @@ export const SURVIVAL: ModSet = Object.freeze({ | ||
| 48 | 48 | ]), |
| 49 | 49 | }); |
| 50 | 50 | |
| 51 | /** | |
| 52 | * Essential Commands' `enable_<name>` keys: the issue's (#18195) list; check `/back` is refused on | |
| 53 | * first start. | |
| 54 | */ | |
| 55 | const EC_ON = ["home", "spawn", "tpa"]; | |
| 56 | const EC_OFF = [ | |
| 57 | "back", "warp", "nick", "rtp", "fly", "workbench", "enderchest", "top", | |
| 58 | "gamemode", "afk", "invuln", "day", "night", "feed", "heal", "repair", | |
| 59 | ]; | |
| 60 | const essentialConfig = (): string => | |
| 61 | [ | |
| 62 | "# Written by the forge with the quality set (#18195): home, spawn and tpa only.", | |
| 63 | ...EC_ON.map((c) => `enable_${c}=true`), | |
| 64 | ...EC_OFF.map((c) => `enable_${c}=false`), | |
| 65 | "use_permissions_api=false", | |
| 66 | "", | |
| 67 | ].join("\n"); | |
| 68 | ||
| 51 | 69 | /** |
| 52 | 70 | * Quality-of-life mods for a Fabric survival server (step 3 of #18059): graves, home/spawn/tpa |
| 53 | 71 | * commands, styled chat, right-click harvest, sleep (night-skip, #18151) and a vein miner (#18152). |
| 54 | 72 | * Optional: a mod that does not build for the server's Minecraft version (rightclickharvest on |
| 55 | * 1.21.6) is skipped and named, not a refusal. Essential Commands ships with every command on; its | |
| 56 | * config is the owner's to trim to /home, /spawn and /tpa. | |
| 73 | * 1.21.6) is skipped and named, not a refusal. Essential Commands is written with its config: | |
| 74 | * /home, /spawn and /tpa on, every other command off, no permission plugin needed (#18195). | |
| 57 | 75 | */ |
| 58 | 76 | export const QUALITY: ModSet = Object.freeze({ |
| 59 | 77 | name: "quality", |
| 60 | 78 | title: "Quality of life", |
| 61 | 79 | key: "q", |
| 62 | about: "Graves, home and spawn commands, styled chat, right-click harvest, a night-skip sleep mod and a vein miner for a Fabric survival server.", | |
| 80 | about: "Graves, /home, /spawn and /tpa, styled chat, right-click harvest, a night-skip sleep mod and a vein miner for a Fabric survival server.", | |
| 63 | 81 | loader: "fabric", |
| 64 | 82 | optional: true, |
| 65 | 83 | slugs: Object.freeze(["universal-graves", "essential-commands", "styled-chat", "rightclickharvest", "sleep-warp", "veinminer"]), |
| 66 | cautions: Object.freeze({ | |
| 67 | "essential-commands": "Essential Commands installs with every command on: before players join, trim its config to /home, /spawn and /tpa.", | |
| 84 | configs: Object.freeze({ | |
| 85 | "essential-commands": Object.freeze({ | |
| 86 | file: "config/EssentialCommands.properties", | |
| 87 | content: essentialConfig(), | |
| 88 | says: "Writes config/EssentialCommands.properties with Essential Commands: /home, /spawn and /tpa on for every player, every other command off, no permission plugin needed", | |
| 89 | }), | |
| 68 | 90 | }), |
| 69 | 91 | why: Object.freeze([ |
| 70 | 92 | "Universal Graves: a death leaves a grave with your items instead of a pile that despawns", |
src/games/mods.ts +6 −4
| @@ -60,7 +60,7 @@ export interface Plan { | ||
| 60 | 60 | /** The modpack the lock holds after it (undefined: as it was). */ |
| 61 | 61 | readonly pack?: LockedPack; |
| 62 | 62 | /** A config file written in the same commit (spark's: where its profiles go). */ |
| 63 | readonly config?: { readonly file: string; readonly content: string }; | |
| 63 | readonly configs?: readonly { readonly file: string; readonly content: string }[]; | |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** The lockfile's path for a service, beside the compose file. */ |
| @@ -239,7 +239,7 @@ export async function planInstall(app: App, m: Mods, service: string, ref: strin | ||
| 239 | 239 | lines: spark === undefined ? lines : [...lines.slice(0, -1), spark.line, ...lines.slice(-1)], |
| 240 | 240 | lock: got.value, |
| 241 | 241 | env: { ...envFor(m, got.value, kept), ...spark?.env }, |
| 242 | ...(spark === undefined ? {} : { config: spark.config }), | |
| 242 | ...(spark === undefined ? {} : { configs: [spark.config] }), | |
| 243 | 243 | message: `games: ${service} mods: add ${title}${deps === 0 ? "" : ` and ${String(deps)} ${deps === 1 ? "dependency" : "dependencies"}`}`, |
| 244 | 244 | sha: m.sha, |
| 245 | 245 | done: `${title} is installed${deps === 0 ? "" : ` with ${String(deps)} ${deps === 1 ? "dependency" : "dependencies"}`}`, |
| @@ -294,14 +294,16 @@ async function planSet(app: App, m: Mods, service: string, set: ModSet): Promise | ||
| 294 | 294 | } |
| 295 | 295 | if (!got.ok) return got; |
| 296 | 296 | const deps = got.value.filter((l) => !l.top && !m.lock.some((o) => o.project === l.project)).length; |
| 297 | const written = Object.entries(set.configs ?? {}).filter(([k]) => missing.includes(k) && !skipped.has(k)).map(([, v]) => v); | |
| 297 | 298 | const what = `the ${set.title.toLowerCase()} set (${missing.filter((x) => !skipped.has(x)).join(", ")})`; |
| 298 | 299 | const withDeps = deps === 0 ? "" : ` and ${String(deps)} ${deps === 1 ? "dependency" : "dependencies"}`; |
| 299 | 300 | return { |
| 300 | 301 | ok: true, |
| 301 | 302 | value: { |
| 302 | 303 | lines: [...diffLines(m, got.value, new Set(adopt)), ...[...skipped].map(([k, v]) => `Left out ${k}: ${v}`), |
| 303 | ...Object.entries(set.cautions ?? {}).filter(([k]) => missing.includes(k) && !skipped.has(k)).map(([, v]) => `Before players join: ${v}`), | |
| 304 | ...written.map((w) => w.says), | |
| 304 | 305 | ], |
| 306 | ...(written.length === 0 ? {} : { configs: written.map(({ file, content }) => ({ file, content })) }), | |
| 305 | 307 | lock: got.value, |
| 306 | 308 | env: envFor(m, got.value, kept), |
| 307 | 309 | message: `games: ${service} mods: add ${what}${withDeps}`, |
| @@ -381,7 +383,7 @@ export async function commitPlan(app: App, user: User, box: GameBox, service: st | ||
| 381 | 383 | what: service, |
| 382 | 384 | edit: (text) => { |
| 383 | 385 | const env = setServiceEnv(text, service, plan.env); |
| 384 | return plan.config === undefined ? env : withConfig(env, service, plan.config.file, plan.config.content); | |
| 386 | return (plan.configs ?? []).reduce((t, c) => withConfig(t, service, c.file, c.content), env); | |
| 385 | 387 | }, |
| 386 | 388 | extra: [{ path: lockPath(box, service), content: lockText(m.target, plan.lock, plan.pack ?? m.pack) }], |
| 387 | 389 | expectTip: plan.sha, |
src/games/presets.ts +1 −1
| @@ -260,7 +260,7 @@ export async function planServer(app: App, box: GameBox, wish: Wish): Promise<Re | ||
| 260 | 260 | const planned = await planInstall(app, m, wish.name, slug); |
| 261 | 261 | if (!planned.ok) return { ok: false, error: `${slug}: ${planned.error}` }; |
| 262 | 262 | pinned = planned.value.lock; |
| 263 | if (planned.value.config !== undefined) files.push(planned.value.config); | |
| 263 | files.push(...(planned.value.configs ?? [])); | |
| 264 | 264 | pluginLines.push(...planned.value.lines); |
| 265 | 265 | const nextEnv = { ...m.env }; |
| 266 | 266 | for (const [k, v] of Object.entries(planned.value.env)) |
test/game-mods.test.ts +40 −9
| @@ -592,20 +592,20 @@ describe("spark's config is installed with the mod", () => { | ||
| 592 | 592 | test("the plan writes the config in the same commit: this forge's store, never the author's paste, and no secret in git", async () => { |
| 593 | 593 | const plan = await planInstall(app, await mods(), "hub", "spark"); |
| 594 | 594 | if (!plan.ok) throw new Error(plan.error); |
| 595 | expect(plan.value.config?.file).toBe("plugins/spark/config.json"); | |
| 595 | expect(plan.value.configs?.[0]?.file).toBe("plugins/spark/config.json"); | |
| 596 | 596 | expect(plan.value.lines.some((l) => l.startsWith("Writes plugins/spark/config.json"))).toBe(true); |
| 597 | const text = plan.value.config!.content; | |
| 597 | const text = plan.value.configs![0]!.content; | |
| 598 | 598 | expect(JSON.parse(text)).toEqual({ bytebinUrl: "${CFG_SPARK_BYTEBIN_URL}", viewerUrl: "http://localhost:0/games/net/@spark/" }); |
| 599 | 599 | expect(text).not.toMatch(/lucko|bytebin\./); |
| 600 | 600 | expect(plan.value.env["CFG_SPARK_BYTEBIN_URL"]).toBe("${SPARK_BASE}"); |
| 601 | 601 | // A Fabric server reads it from config/. |
| 602 | 602 | const fabric = await planInstall(app, await mods("smp"), "smp", "spark"); |
| 603 | 603 | if (!fabric.ok) throw new Error(fabric.error); |
| 604 | expect(fabric.value.config?.file).toBe("config/spark/config.json"); | |
| 604 | expect(fabric.value.configs?.[0]?.file).toBe("config/spark/config.json"); | |
| 605 | 605 | // Another mod writes none. |
| 606 | 606 | const other = await planInstall(app, await mods(), "hub", "worldedit"); |
| 607 | 607 | if (!other.ok) throw new Error(other.error); |
| 608 | expect(other.value.config).toBeUndefined(); | |
| 608 | expect(other.value.configs).toBeUndefined(); | |
| 609 | 609 | |
| 610 | 610 | const done = await commitPlan(app, alice, box, "hub", await mods(), plan.value); |
| 611 | 611 | if (!done.ok) throw new Error(done.error); |
| @@ -907,12 +907,43 @@ describe("the quality-of-life set (#18089)", () => { | ||
| 907 | 907 | expect(left.value.lines).toContain("Left out veinminer: Veinminer has no version for Fabric 1.21.8."); |
| 908 | 908 | }); |
| 909 | 909 | |
| 910 | test("Essential Commands' plan says to trim it before players join, on the page's preview and the terminal's", async () => { | |
| 910 | test("installing the quality set writes Essential Commands' config: only home, spawn and tpa on (#18195)", async () => { | |
| 911 | 911 | const planned = await planInstall(app, await mods("smp"), "smp", "set:quality"); |
| 912 | 912 | if (!planned.ok) throw new Error(planned.error); |
| 913 | expect(planned.value.lines).toEqual(expect.arrayContaining([expect.stringContaining("Before players join: Essential Commands installs with every command on")])); | |
| 913 | expect(planned.value.lines.some((l) => l.startsWith("Writes config/EssentialCommands.properties"))).toBe(true); | |
| 914 | 914 | const page = await (await asAlice("/games/net/smp?add=set:quality")).text(); |
| 915 | expect(page).toContain("trim its config to /home, /spawn and /tpa"); | |
| 915 | expect(page).toContain("Writes config/EssentialCommands.properties"); | |
| 916 | const done = await commitPlan(app, alice, box, "smp", await mods("smp"), planned.value); | |
| 917 | if (!done.ok) throw new Error(done.error); | |
| 918 | const compose = (await readCompose(app, box))!; | |
| 919 | const file = configMounts(compose.text, "smp").find((c) => c.file === "config/EssentialCommands.properties"); | |
| 920 | if (file === undefined) throw new Error("config/EssentialCommands.properties is missing after installing the quality set"); | |
| 921 | const keys = Object.fromEntries(file.content.split("\n").filter((l) => /^[a-z_]+=/.test(l)).map((l) => l.split("=") as [string, string])); | |
| 922 | expect(Object.entries(keys).filter(([k, v]) => k.startsWith("enable_") && v === "true").map(([k]) => k).sort()).toEqual(["enable_home", "enable_spawn", "enable_tpa"]); | |
| 923 | for (const c of ["back", "warp", "nick", "rtp", "fly", "workbench", "enderchest", "top", "gamemode", "afk", "invuln", "day", "night", "feed", "heal", "repair"]) | |
| 924 | expect(keys[`enable_${c}`]).toBe("false"); | |
| 925 | expect(keys["use_permissions_api"]).toBe("false"); | |
| 926 | // Put the server back, then: with Essential Commands left out of a plan nothing is written. | |
| 927 | for (const l of (await mods("smp")).lock.filter((x) => x.top)) { | |
| 928 | const r = await planRemove(await mods("smp"), "smp", l.slug); | |
| 929 | if (!r.ok) continue; | |
| 930 | const u = await commitPlan(app, alice, box, "smp", await mods("smp"), r.value); | |
| 931 | if (!u.ok) throw new Error(u.error); | |
| 932 | } | |
| 933 | expect((await mods("smp")).lock).toEqual([]); | |
| 934 | // Essential Commands already installed on its own: the set writes it no config. | |
| 935 | const ec = await planInstall(app, await mods("smp"), "smp", "essential-commands"); | |
| 936 | if (!ec.ok) throw new Error(ec.error); | |
| 937 | const ecDone = await commitPlan(app, alice, box, "smp", await mods("smp"), ec.value); | |
| 938 | if (!ecDone.ok) throw new Error(ecDone.error); | |
| 939 | const rest = await planInstall(app, await mods("smp"), "smp", "set:quality"); | |
| 940 | if (!rest.ok) throw new Error(rest.error); | |
| 941 | expect(rest.value.configs).toBeUndefined(); | |
| 942 | expect(rest.value.lines.some((l) => l.startsWith("Writes config/"))).toBe(false); | |
| 943 | const last = await planRemove(await mods("smp"), "smp", "essential-commands"); | |
| 944 | if (!last.ok) throw new Error(last.error); | |
| 945 | const lastDone = await commitPlan(app, alice, box, "smp", await mods("smp"), last.value); | |
| 946 | if (!lastDone.ok) throw new Error(lastDone.error); | |
| 916 | 947 | }); |
| 917 | 948 | |
| 918 | 949 | test("two members that need Fabric API share one copy of it", async () => { |
| @@ -982,7 +1013,7 @@ describe("the quality-of-life set (#18089)", () => { | ||
| 982 | 1013 | const screen = gameModsScreen(session, tui.ctx, box, "smp"); |
| 983 | 1014 | const owners = screen.keys.flatMap((b) => b.keys); |
| 984 | 1015 | for (const set of SETS) expect(owners.filter((k) => k === set.key)).toHaveLength(1); |
| 985 | expect(QUALITY.cautions).toBeDefined(); | |
| 1016 | expect(QUALITY.configs).toBeDefined(); | |
| 986 | 1017 | const page = await (await asAlice("/games/net/smp")).text(); |
| 987 | 1018 | expect(page).toContain(`Preview the ${QUALITY.title} set`); |
| 988 | 1019 | expect(page).not.toContain("Preview the set"); |
| @@ -1001,7 +1032,7 @@ describe("the quality-of-life set (#18089)", () => { | ||
| 1001 | 1032 | terminal.feed("q"); |
| 1002 | 1033 | await settleUntil(tui, "Left out rightclickharvest"); |
| 1003 | 1034 | terminal.feed("y"); |
| 1004 | await settleUntil(tui, "is installed"); | |
| 1035 | await settleUntil(tui, "set (universal-graves"); | |
| 1005 | 1036 | expect((await mods("smp")).lock.map((l) => l.slug)).toEqual(expect.arrayContaining(["essential-commands", "styled-chat", "universal-graves"])); |
| 1006 | 1037 | tui.stop?.(); |
| 1007 | 1038 | }); |
new above
offline
cautionsis now used by no set. Remove the field and its branch in mods.ts.