Skip to content

Config Groups

Gustavo Malvestiti edited this page Aug 16, 2026 · 1 revision

Annotate a shell class with @ConfigGroup to manage multiple config files through one holder. Each non-static, non-transient field whose declared type carries @Config becomes its own file. The file names come from the member types' own @Config annotations — keep them inside your mod's path to avoid collisions:

@Config(name = "client", path = "mymod")
public final class ClientConfig {
    public boolean showHints = true;
}

@Config(name = "server", path = "mymod")
public final class ServerConfig {
    public int maxPlayers = 20;
}

@ConfigGroup
public final class ModConfigs {
    public ClientConfig client = new ClientConfig();
    public ServerConfig server = new ServerConfig();
}
ConfigHolder<ModConfigs> configs = EasyConfig.holder(ModConfigs.class).modId("mymod").create();
// reads and writes config/mymod/client.json5 and config/mymod/server.json5
boolean hints = configs.data().client.showHints;

Group rules:

  • Members must be non-final (group loads replace the references).
  • No two members may share a config type — both fields would resolve to the same file.
  • Non-@Config fields in the group class are silently ignored for persistence and validation.
  • @ConfigIgnore can exclude a @Config-typed member from the group entirely.

Lifecycle with groups: member hooks run first on load and validate; the group root runs first on save. Each member may independently implement ConfigExtension.

Partial failure recovery: when one member's file is corrupt, only that member falls back to defaults. Other members load normally. Each bad file is backed up independently.

Clone this wiki locally