Package com.enhancedechest.config
Class YamlMigrator
java.lang.Object
com.enhancedechest.config.YamlMigrator
Generic YAML migrator that runs on startup for every config/language file.
Three things it does (in order):
- Apply key renames — transfers the user's old value to the new key name.
- Add missing keys — fills in any key absent from the user's file with the bundled default.
- Write to disk — only when at least one change was made.
User values for existing, unchanged keys are NEVER touched.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA key rename for one specific version upgrade. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanmigrate(File file, InputStream defaultStream, List<YamlMigrator.Rename> renames, org.slf4j.Logger log) MigratesfileagainstdefaultStream.
-
Method Details
-
migrate
public static boolean migrate(File file, InputStream defaultStream, List<YamlMigrator.Rename> renames, org.slf4j.Logger log) MigratesfileagainstdefaultStream.- Parameters:
file- the on-disk YAML file to upgradedefaultStream- the bundled resource stream with canonical default keys/valuesrenames- ordered list of key renames (applied before filling missing keys)log- logger for summary output- Returns:
trueif the file was modified and saved
-