# Set what is saved by default

> Decide whether profiles save your mod's settings without being asked, and which keys stay per instance, with savedByDefault and excludedByDefault.

URL: https://xichil.dev/docs/settings-saver/v1/guides/defaults/ · Updated: 2026-11-16 · Applies to: Fabric, Quilt, Legacy Fabric, Forge, NeoForge, MC 1.7.10 - 26.3

Two builder calls set the starting point for every profile: whether your mod is saved at all, and which
keys are left out. The player can change both per profile, and the player's choice always wins.

## Prerequisites

- [Your first integration](https://xichil.dev/docs/settings-saver/v1/getting-started/first-integration/index.md)

## Saved by default, or not

By default a registered mod is **off**: nothing of it is saved or loaded until the player turns it on
for a profile.

```java
ModSettings.builder("mymod", "My Mod", "2.1.0")
        .file("config/mymod.properties", SettingsFileFormats.PROPERTIES)
        .savedByDefault(true)
        .build();
```

With `.savedByDefault(true)`, every profile saves your mod's settings unless the player turned that off.

| Your settings are… | Use |
| --- | --- |
| the player's own: controls, accessibility, HUD layout | `.savedByDefault(true)` |
| usually part of a modpack's setup: gameplay tweaks, server lists a pack ships | leave it off |
| a mix | leave it off, or turn it on and [exclude](#exclude-keys-by-default) the pack-specific keys |

How the player's choice is stored: a line `enabled.mymod=true` or `enabled.mymod=false` in the profile's
`profile.properties`. Without that line, your default applies.

| `savedByDefault` | Player's line | Saved? |
| --- | --- | --- |
| not called, or `false` | none | no |
| not called, or `false` | `enabled.mymod=true` | yes |
| `true` | none | yes |
| `true` | `enabled.mymod=false` | no |

## Exclude keys by default

Some values belong to one machine or one instance: window positions, absolute paths, the last world or
server joined, caches. Excluded keys are neither saved into the profile nor loaded from it, so each
instance keeps its own value.

```java
ModSettings.builder("mymod", "My Mod", "2.1.0")
        .file("config/mymod.properties", SettingsFileFormats.PROPERTIES)
        .excludedByDefault("lastServer", "window.*")
        .build();
```

Pattern rules:

| Pattern | Matches |
| --- | --- |
| `lastServer` | the key `lastServer`, exactly |
| `window.*` | every key that starts with `window.`, such as `window.x` and `window.y` |
| `key_*` | every key that starts with `key_` |

- A `*` only has a meaning at the end of a pattern.
- Keys are the ones your [format](https://xichil.dev/docs/settings-saver/v1/guides/choosing-a-format/index.md) reads. For a `WHOLE_FILE` file the only key is
  `content`.
- The patterns apply to **every** file of your mod.
- You can call `excludedByDefault` more than once. Patterns add up, duplicates are ignored and surrounding
  whitespace is removed.
- A pattern that is null, blank or contains `,` throws `IllegalArgumentException`. Profiles store the list
  separated by commas.

### Defaults stop applying once the player edits the list

A profile follows your list until the player edits your mod's exclusions in that profile. From then on
the profile keeps the player's list, stored as `exclude.mymod=` in `profile.properties`. Changes to your
defaults in later versions of your mod don't reach that profile. The player can reset the list to your
defaults in the **Excluded settings** screen.

So choose the defaults carefully in your first release, and don't rely on a later version adding one.

## Example: on by default, machine-specific keys excluded

```java title="MyModSettingsSaver.java"
@Override
public void register(SettingsSaverRegistrar registrar) {
    registrar.register(ModSettings.builder("mymod", "My Mod", "2.1.0")
            .file("config/mymod.properties", SettingsFileFormats.PROPERTIES)
            .savedByDefault(true)                         // HUD layout and controls follow the player
            .excludedByDefault("window.*", "lastServer")  // these stay with the instance
            .excludedByDefault("cacheDir")
            .build());
}
```

## Next steps

- [Saving other mods' settings](https://xichil.dev/wiki/settings-saver/v1/guides/other-mods/index.md) in the wiki: what the
  player sees and edits.
- [Merge dependent settings](https://xichil.dev/docs/settings-saver/v1/guides/merging/index.md): when excluding is not enough because settings depend on each other.
