Merge pull request #1009 from ludovic111/feat/server-config-command

🤖 Agent: merged after verify and CI parity passed (40 server tests; the whole create → start → join → whitelist → backup → restore → update → stop flow ran on the Mac mini and the ThinkPad). Adds `horizon-server config`, `backups --json`, `update --check --json`; fixes whitelisting on offline servers and updates as root in containers.
This commit is contained in:
Ludovic Marie
2026-10-19 16:21:56 +02:00
committed by GitHub
8 changed files with 446 additions and 13 deletions
+14 -2
View File
@@ -13,7 +13,10 @@ plan are in [docs/server.md](https://github.com/ludovic111/horizon/blob/main/doc
- **Names you add are accounts** (release v2026.10.17.14 and newer). `init --player`, `horizon-server
whitelist add` and `op`, and the console's `whitelist add`, `op` and `ban` look a name up the way vanilla
does: players already seen (kept in `usercache.json`), then Mojang's profile service. In online mode a name
with no account is refused. So you can whitelist friends before they first join.
with no account is refused. So you can whitelist friends before they first join. On an offline server,
`horizon-server whitelist add` always writes the offline UUID, the one the player joins with, also while
the server runs (it writes the entry and the game reloads the list): the console's own `whitelist add`
takes the account's UUID when someone owns that name, as vanilla does, and that player is then refused.
- **Horizon's own client can't sign in to a Microsoft account yet.** That needs an Azure app registration and
Mojang's approval, which the project doesn't have
([docs/microsoft-account.md](https://github.com/ludovic111/horizon/blob/main/docs/microsoft-account.md)).
@@ -199,11 +202,13 @@ horizon-server op|deop NAME
horizon-server whitelist on|off|list
horizon-server whitelist add|remove NAME
horizon-server backup [NAME] back up now
horizon-server backups list the backups
horizon-server backups [--json] list the backups
horizon-server restore BACKUP [--yes]
horizon-server service install|uninstall|print [--system]
horizon-server panel a one-time login link for the web panel
horizon-server import FILE server.toml from a vanilla server.properties
horizon-server config [--json] the settings in server.toml
horizon-server config set KEY=VALUE... change settings, checked first (below)
horizon-server update [--check] install the newest release and restart on it (below)
horizon-server rollback back to the release before
```
@@ -212,6 +217,13 @@ While the server runs, `op`, `whitelist` and `cmd` go to the game's console, so
console commands do. While it's stopped, they edit vanilla's files directly. Any console command works through
`cmd`: `horizon-server cmd ban Griefer`, `horizon-server cmd say Restarting in 5 minutes`.
`config set` changes `server.toml` without opening it: `horizon-server config set world.difficulty=hard
server.max_players=10`. Each key is a section and a name from the file (`properties.spawn-protection=0` for any
other vanilla key). The values are checked as the server checks them, and nothing is written if one is wrong.
A running server takes the difficulty, the default game mode, the whitelist and the backup settings at once;
the rest applies at its next start, and `config set` says which. `--json` prints that as `saved`, `applied`
and `restart`.
The server restarts the game by itself if it crashes: after 5 s, then waiting longer each time, up to 5
minutes. It keeps the crash report and gives up after 5 crashes in 10 minutes, and `status` says why.
+7 -3
View File
@@ -308,9 +308,12 @@ a typed key set again under `[properties]` and values vanilla would refuse. Plan
After it stops, the supervisor compares the file with what it wrote and copies any changed keys back into
`server.toml`, so an in-game change survives the next start. Edits go through `toml_edit`, so the owner's
comments and order are kept.
- **Reload (planned).** The four lists already reload through the engine (`whitelist reload`). `reload` will
send what can change live and say which settings need a restart. A real hot reload (view distance, MOTD) needs engine
support and comes later.
- **Changes without opening the file.** `horizon-server config set KEY=VALUE...` (the launcher's Servers
page uses it) writes through `toml_edit`, checks the result as `server.toml` is checked, and writes nothing
if a value is wrong. On a running server it sends what vanilla changes live through its console:
`difficulty`, `defaultgamemode` and `whitelist on|off`; the backup settings apply at once because the
supervisor reads them each time. Everything else waits for the next start, and the command says which. A
real hot reload (view distance, MOTD) needs engine support and comes later.
- `server.properties`, `ops.json`, `whitelist.json`, `banned-*.json` and `world/` keep vanilla's names and
formats. A vanilla server folder works as is, and so does going back to vanilla.
@@ -327,6 +330,7 @@ horizon-server op|deop <player>
horizon-server whitelist on|off|list|add|remove [player]
horizon-server backup [NAME] backups restore <backup> [--yes]
horizon-server import <server.properties>
horizon-server config [--json] config set KEY=VALUE... [--json]
horizon-server service install|uninstall|print [--system]
horizon-server panel the panel's address and a one-time login link
horizon-server update [--check] [--version vX.Y.Z] [--timeout S] rollback [--timeout S]