Settings Saver API docs
Let Settings Saver save, load and sync your mod's own settings files through its profiles, on every loader from Minecraft 1.7.10 to 26.3.
Settings Saver keeps a player's settings in profiles outside any one game instance and applies them to
every instance that uses the profile. Out of the box it handles Minecraft's options.txt. With this API
your mod's own settings files are saved, loaded and synced the same way.
Settings Saver stays an optional dependency. Your mod compiles against a small API jar, and when the player doesn't have Settings Saver installed, your mod runs exactly as before.
The whole integration is one class and one text file:
package com.example.mymod.compat;
import dev.xichil.settingssaver.api.v1.ModSettings;
import dev.xichil.settingssaver.api.v1.SettingsFileFormats;
import dev.xichil.settingssaver.api.v1.SettingsSaverPlugin;
import dev.xichil.settingssaver.api.v1.SettingsSaverRegistrar;
/** Only Settings Saver loads this class. Nothing else in the mod may reference it. */
public final class MyModSettingsSaver implements SettingsSaverPlugin {
@Override
public void register(SettingsSaverRegistrar registrar) {
registrar.register(ModSettings.builder("mymod", "My Mod", "2.1.0")
.file("config/mymod.properties", SettingsFileFormats.PROPERTIES)
.build());
}
}
com.example.mymod.compat.MyModSettingsSaver
Key facts#
| Package | dev.xichil.settingssaver.api.v1 |
| Maven repository | https://maven.xichil.dev |
| API artifact | dev.xichil.settingssaver:settingssaver-api:1.0.0, as compileOnly (never bundle it) |
| Settings Saver's mod id | settingssaver (SettingsSaverMods.MOD_ID), the same on every loader |
| Java | the API is plain Java 8 with no dependencies: no Minecraft, loader or Settings Saver classes |
| Loaders and versions | every one Settings Saver supports: Fabric, Quilt, Legacy Fabric, Forge and NeoForge, Minecraft 1.7.10 to 26.3 |
| Side | client only; nothing is synced on a dedicated server |
| Entry point | a SettingsSaverPlugin class listed in a META-INF/services file |
| Files | UTF-8 text files inside the game directory |
| Default | a mod's settings are not saved until the player turns the mod on for a profile, unless the mod asks for savedByDefault(true) |
| Compatibility | the v1 package only changes compatibly; a breaking change would be a new v2 package next to it |
| Javadoc | the api.v1 package and every class in it |
Start here#
- Installation: add the Maven repository and the
compileOnlydependency. - Your first integration: the plugin class, the service file, and how to check that your file reaches a profile.
- Build one integration for every loader: ship the same plugin class in every jar of a multi-loader, multi-version mod.
Find the page you need#
| I want to… | Page |
|---|---|
| sync one file, several files or a whole folder | Register files and directories |
| sync single settings instead of whole files | Choose a file format |
| sync a TOML, JSON, INI or other structured file key by key | Write your own file format |
| have my settings saved without the player turning it on | Set what is saved by default |
| keep window positions, paths or caches out of profiles | Set what is saved by default |
| rename a key or change a value in a new version of my mod | Convert settings between mod versions |
| store a setting differently on older Minecraft versions | Convert settings between Minecraft versions |
| handle settings that depend on each other | Merge dependent settings |
| read my config at the right moment on each loader | Read your config after the restore |
| ship one mod for Fabric, Forge and NeoForge, old and new | Build one integration for every loader |
| register without a service file | Register from your own code |
| test formats and fixes in JUnit | Test your integration without Minecraft |
| find out why nothing is synced | Fix an integration that doesn't sync |
| look up a class or method | The API at a glance |
All pages#
Getting started
- Installation: repository, dependency, what not to bundle.
- Your first integration: five steps to a synced file.
Guides (how to do one task)
- Register files and directories:
file,directoryand the path rules. - Choose a file format:
WHOLE_FILE,PROPERTIES,KEY_VALUEor your own. - Write your own file format: implement
SettingsFileFormat. - Set what is saved by default:
savedByDefaultandexcludedByDefault. - Convert settings between mod versions:
modVersionFix. - Convert settings between Minecraft versions:
minecraftFix. - Merge dependent settings:
SettingsMerger. - Read your config after the restore: the right event on each loader.
- Build one integration for every loader: shared plugin class, one jar per loader family.
- Register from your own code:
SettingsSaverMods.register. - Test your integration without Minecraft: JUnit tests for formats, fixes and mergers.
- Fix an integration that doesn't sync: log lines and their causes.
Concepts (how it works)
- How syncing works: profiles, key-by-key saving, where files are stored.
- An optional dependency: why the service file can't crash your mod.
- When plugins run: the launch timeline on each loader.
- How settings are converted: the profile's form and the order fixes run in.
- Threads and errors: what is called from where, and what happens when it throws.
- The API at a glance: every class and method on one page.
Examples (complete, copyable)
- A properties config: the smallest complete integration.
- A sectioned config file: a custom format that flattens
[section]headers. - Settings across versions: three mod versions and two Minecraft eras, one profile.
- A multi-loader mod: every file of a mod that ships for all loaders.
Players and server admins#
The wiki explains how to install and use Settings Saver. Saving other mods' settings is the page to point your players to.
Start here
- Installation
- Your first integration
- Register files and directories
- Choose a file format
- Write your own file format
- Set what is saved by default
- Convert settings between mod versions
- Convert settings between Minecraft versions
- Merge dependent settings
- Read your config after the restore
- Build one integration for every loader
- Register from your own code
- Test your integration without Minecraft
- Fix an integration that doesn't sync