feat: /save admin command to force a world snapshot #41

Closed
opened 2026-07-18 05:12:38 +02:00 by marco · 0 comments
Owner

Give admins a chat command to force an immediate world save instead of waiting for the 15s periodic snapshot (e.g. before a restart or after a notable event).

Scope

  • Extract the snapshot-gather + flush logic (today private in PersistenceService) into a shared WorldPersister service, with concurrent-save dedupe (a single shared instance so the periodic save and a manual save never write the file at the same time).
  • PersistenceService uses WorldPersister (timer + shutdown).
  • New /save GmCommand (admin-only, authorized server-side by the signed admin JWT claim via CanExecute) that triggers a save and returns a SystemMessage with the outcome.
  • Add the /save row to docs/gm-commands.md.

Definition of Done

  • /save run by an admin writes world.sav immediately (not waiting the 15s periodic) and replies with a system message reporting how many players were saved.
  • A non-admin who sends /save gets You are not allowed to do that. and their command writes no file.
  • /save with no players online replies that there is nothing to save and writes no file.
  • A save requested while another is in progress is skipped and replies that a save is already running (dedupe through the single shared WorldPersister).
  • The periodic PersistenceService and the /save command both persist through WorldPersister (one code path, identical on-disk result).
  • docs/gm-commands.md lists a /save row.

Depends on the binary-persistence PR (#40): PlayerStore/world.sav land there.

Give admins a chat command to force an immediate world save instead of waiting for the 15s periodic snapshot (e.g. before a restart or after a notable event). ## Scope - Extract the snapshot-gather + flush logic (today private in `PersistenceService`) into a shared `WorldPersister` service, with **concurrent-save dedupe** (a single shared instance so the periodic save and a manual save never write the file at the same time). - `PersistenceService` uses `WorldPersister` (timer + shutdown). - New `/save` `GmCommand` (admin-only, authorized server-side by the signed `admin` JWT claim via `CanExecute`) that triggers a save and returns a `SystemMessage` with the outcome. - Add the `/save` row to `docs/gm-commands.md`. ## Definition of Done - [ ] `/save` run by an admin writes `world.sav` immediately (not waiting the 15s periodic) and replies with a system message reporting how many players were saved. - [ ] A non-admin who sends `/save` gets `You are not allowed to do that.` and their command writes no file. - [ ] `/save` with no players online replies that there is nothing to save and writes no file. - [ ] A save requested while another is in progress is skipped and replies that a save is already running (dedupe through the single shared `WorldPersister`). - [ ] The periodic `PersistenceService` and the `/save` command both persist through `WorldPersister` (one code path, identical on-disk result). - [ ] `docs/gm-commands.md` lists a `/save` row. Depends on the binary-persistence PR (#40): `PlayerStore`/`world.sav` land there.
marco closed this issue 2026-07-18 08:32:46 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
marco/IsoMmo#41
No description provided.