Persistence
Store isolated player, server and world state with atomic writes and explicit schema migration.
Scopes and paths
| API | Data path | Use |
|---|---|---|
| Versioned server | addon_data/<id>/server/<key>.json | State shared by the server. |
| Versioned world | addon_data/<id>/world/<map-or-world>/<key>.json | State isolated by current map name or explicit world id. |
| Versioned player | addon_data/<id>/players/<steamId>/<key>.json | Named per-player documents with migration. |
| Legacy player blob | addon_data/<id>/<steamId>.json | One unversioned object retained for compatibility. |
Versioned result
LitherarpAddonDataResult<T> exposes Value, Success, Exists, Migrated, StoredVersion and Error. A missing file succeeds with a new value. A schema mismatch without a migration fails and does not guess.
A successful migration is saved synchronously before load returns. The migration receives the old version and a cloned JsonElement containing the old data value.
Durability
Saves use atomic latest-write-wins queueing by default. The in-memory latest-write cache gives immediate read-after-save behavior. Pass synchronous: true only when the caller needs immediate disk durability. Context teardown calls FlushAddonData so the latest cached documents are written before shutdown completes.
Limits
- Maximum serialized document size: 1,048,576 UTF-8 bytes.
- Maximum versioned documents per scope: 128.
- Keys and explicit world ids: at most 64 characters, using lowercase letters, digits, dot, underscore and hyphen.
- Schema versions must be positive integers.
Public config sections and targeted player sections are transport state, not durable storage. Save the authoritative value here and sync only what UI needs.