How syncing works
What Settings Saver does with a registered settings file, from the launch restore to key-by-key saving, and where a profile stores your mod's files.
On this page
Settings Saver keeps one copy of your mod's settings per profile, outside every game instance, and moves settings between that copy and each instance's file. It works setting by setting, so instances don't overwrite each other.
The pieces#
| Term | Meaning |
|---|---|
| Instance | One game directory: a modpack, a launcher profile, one Minecraft version. |
| Store | One folder per user, shared by every instance on the computer. |
| Profile | A named set of saved settings in the store. Each instance picks one; default always exists. |
| Registration | Your ModSettings: which files, how to read them, the defaults and the fixes. |
| Format | Reads a file into a flat key -> value map and writes it back. |
What happens to a registered file#
launch while playing on demand
profile ----------> instance file instance file ----------> profile Save / Load buttons
(only if the file is missing, (only the keys that changed,
or sync is Auto + always apply) only when sync is Auto)
1. Registration#
Your plugin hands over a ModSettings early in the launch. Settings Saver checks it against the other
registrations and, if the profile has your mod turned on, starts syncing its files.
2. Restore at launch#
For each of your files:
- If the instance doesn't have the file, it is written from the profile's copy, converted to this instance's Minecraft version.
- If the instance has the file, it is left alone. The exception is the sync mode Auto + always apply, which backs the file up and applies the profile over it at every launch.
With sync Off (the default), this restore happens once per instance, on its first launch with Settings Saver. With Auto, it happens whenever a file is missing at launch.
An empty profile restores nothing, and an instance never fills a profile on its own.
3. Saving changes#
Settings reach the profile in two ways:
- Save settings to profile, the button in Settings Saver's menu, in every sync mode.
- Auto sync: a background thread checks your file every 2 seconds. Once the file has changed and then stayed the same for one more check, the changes are saved. A final check runs when the game closes.
Either way, with a key-by-key format only the settings that changed since the last sync are written. The rest of the profile's copy stays as it is. Two instances that changed different settings both keep their change.
A setting that newly appears in your file (your mod added it with its default) only fills a gap in the profile. It never replaces a value that is already saved there.
4. Loading#
Load settings from profile backs up the instance's file, then merges the profile's values over it. Keys the profile excludes, or doesn't have, keep the instance's values.
Key by key, or as a whole#
Everything above works per key, as your format defines keys. With the default WHOLE_FILE format the
file has a single key, content, so:
| Key-by-key format | WHOLE_FILE |
|
|---|---|---|
| A save writes | the changed keys | the whole file, when anything changed |
| Two instances change the file | both changes kept, per key | the newest save wins |
| A load | merges over the instance's file | replaces the instance's file |
| Exclusions | per key | only the whole file |
See Choose a file format.
Off unless chosen#
A registered mod is listed in Settings Saver, but its files are synced for a profile only when:
- the player turned the mod on for that profile (
enabled.<mod id>=true), or - the mod asked for
savedByDefault(true)and the player didn't turn it off.
Turning a mod on or off applies nothing by itself: syncing starts from the instance's current files, and turning it off leaves what the profile has saved.
Where a profile keeps your files#
<store>/
profiles/
default/
profile.properties enabled.mymod=, exclude.mymod=, and the same for other mods
vanilla/options.txt Minecraft's own settings
mymod/
module.txt modVersion and dataVersion the settings were saved in
config/mymod.properties your file, at its path in the game directory
- Your folder is named after your mod id. Change the id and your mod starts from an empty folder.
- The profile's copy is written with the same format as your file.
module.txtis what lets another version convert the settings. See How settings are converted.- Backups of files that a Load or Auto + always apply replaced go to
<store>/backups/<mod id>/.
Several instances at once#
Instances that run at the same time share the store. Every read-modify-write of a profile runs under a lock that works across processes, and files are replaced atomically, so a profile is never half written. Your format, fixes and merger may therefore be called while the profile is locked: keep them quick.
Related#
- For players: Sync modes and Saving other mods' settings.
- When plugins run
- Threads and errors