diff --git a/gradle.properties b/gradle.properties index 51c3bf4..3cff1ae 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ loader_version=0.15.11 fabric_version=0.77.0+1.19.2 # Mod Properties -mod_version=1.6+1.19.2 +mod_version=1.6.1+1.19.2 maven_group=jerozgen archives_base_name=language-reload diff --git a/src/main/java/jerozgen/languagereload/config/Config.java b/src/main/java/jerozgen/languagereload/config/Config.java index 3a17821..a7d2aff 100644 --- a/src/main/java/jerozgen/languagereload/config/Config.java +++ b/src/main/java/jerozgen/languagereload/config/Config.java @@ -6,6 +6,7 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.util.Language; import java.nio.file.Files; import java.nio.file.Path; @@ -19,6 +20,8 @@ public class Config { private static Config INSTANCE; + public int version = 0; + public boolean multilingualItemSearch = true; public LinkedList fallbacks = new LinkedList<>(); public LinkedList previousFallbacks = new LinkedList<>(); @@ -38,6 +41,8 @@ public static void load() { LanguageReload.LOGGER.error("Couldn't load config file: ", e); } + migrateToVersion1(); + if (INSTANCE.language.equals(LanguageReload.NO_LANGUAGE_CODE) && !INSTANCE.fallbacks.isEmpty()) { INSTANCE.language = INSTANCE.fallbacks.pollFirst(); } @@ -59,4 +64,21 @@ public static Config getInstance() { if (INSTANCE == null) load(); return INSTANCE; } + + private static void migrateToVersion1() { + if (INSTANCE.version >= 1) return; + INSTANCE.version = 1; + + if (!INSTANCE.language.isEmpty() + && !INSTANCE.language.equals(Language.DEFAULT_LANGUAGE) + && !INSTANCE.fallbacks.contains(Language.DEFAULT_LANGUAGE)) + INSTANCE.fallbacks.add(Language.DEFAULT_LANGUAGE); + + if (!INSTANCE.previousLanguage.isEmpty() + && !INSTANCE.previousLanguage.equals(Language.DEFAULT_LANGUAGE) + && !INSTANCE.previousFallbacks.contains(Language.DEFAULT_LANGUAGE)) + INSTANCE.previousFallbacks.add(Language.DEFAULT_LANGUAGE); + + save(); + } }