Package net.mezzdev.config.api.migration
@NullMarked
package net.mezzdev.config.api.migration
Import settings and persistent sort orders from files that a mod used before adopting MezzConfig.
Declare the destination values, then register the old file locations and a parser on the schema builder:
IConfigRegistration registration = Configs.forMod("example");
IConfigSchemaBuilder schema = registration.createClientSchemaBuilder("example.ini", "config.example");
IConfigValue<Boolean> enabled = schema.addCategory("general")
.addBoolean("enabled", true)
.build();
schema.setLegacyMigration(List.of(oldConfigPath), (path, migration) -> {
List<String> oldLines = Files.readAllLines(path);
migration.set(enabled, oldLines.contains("enabled=true"));
});
schema.build();
The parser only needs to understand the old format. MezzConfig backs up the source, validates all migrated values, and
writes its current format without exposing that format to the mod.
To load a MezzConfig file from an older location, use
IConfigSchemaBuilder.setLegacySources(List). To rename, move, or convert a value while importing that legacy
source, use the legacy methods on IConfigValueBuilder.
-
ClassDescriptionDescribes the outcome of a registered legacy config migration.Imports converted legacy settings without exposing MezzConfig's file format.Reports the final outcome of a registered legacy migration.Imports a config file from the format a mod used before adopting MezzConfig.Supplies a converted legacy order to a sorting config.Imports a saved order from the format a mod used before adopting a MezzConfig sorting config.