When plugins run

The point in the launch at which Settings Saver calls your plugin and restores your files on each loader and version, and what that means for your mod.

Last updated

On this page

Settings Saver calls your plugin's register exactly once per launch, as early as the loader allows. How early depends on the loader and its version.

The timeline per loader#

Loader Plugins run Before Minecraft reads its options?
Fabric, Quilt, Legacy Fabric at preLaunch yes
Forge 1.15.2 (31.2 and newer) to 26.3, NeoForge while the launch is set up, from Settings Saver's mixin config plugin yes
Forge 1.13.2 to 1.15.2 (31.1) in Settings Saver's @Mod constructor no
Forge 1.7.10 to 1.12.2 in Settings Saver's @Mod constructor, still before preInit no

On Forge 1.7.10 to 1.12.2, other mods' jars only join the class path when Forge discovers mods, so the @Mod constructor is the first moment your plugin can be found.

What is guaranteed everywhere#

What that means for the plugin class#

register may run before the game, the loader's mod list or your own mod are set up. Inside it:

Do Don't
Build a ModSettings and pass it to the registrar Touch Minecraft or loader classes
Use constants and plain Java Load or parse your config
Return quickly Do slow I/O or network calls
Rely on throwing: an exception is caught and logged, and nothing of your mod is synced from that call

The registrar is meant to be used during the register call only. To register later, use SettingsSaverMods.

Early and late registrations#

Registration made What it gets
before Minecraft reads its options takes part in the launch's restore: an instance without the file gets the profile's copy
later (Forge rows 3 and 4, or from code) starts syncing at once, and still gets that restore if this launch did one
before Settings Saver started (from code only) kept, and handed over in order when Settings Saver starts

Why ServiceLoader#

java.util.ServiceLoader is part of the JDK. It behaves the same on every loader without loader-specific code, and its service file only links your class when Settings Saver asks for it. On Forge 1.17 and newer and on NeoForge, a jar's service files become provides clauses of its automatic module, so the same file also works with their module layers.