From 76abc2f82f4bc777fbc00cf7cdb7a0fbdad5f62c Mon Sep 17 00:00:00 2001 From: NikitaCartes Date: Sun, 29 Dec 2024 02:42:09 +0100 Subject: [PATCH] Fix loading wrong config --- build.gradle | 7 +++---- gradle.properties | 6 +++--- .../glowingeyeblossom/config/ConfigTemplate.java | 12 +++++++----- .../glowingeyeblossom/config/MainConfigV1.java | 4 ++-- src/main/resources/fabric.mod.json | 2 +- .../nikitacartes/glowingeyeblossom}/config/main.conf | 0 6 files changed, 16 insertions(+), 15 deletions(-) rename src/main/resources/{ => xyz/nikitacartes/glowingeyeblossom}/config/main.conf (100%) diff --git a/build.gradle b/build.gradle index 4bb8ed4..b7c4b3a 100644 --- a/build.gradle +++ b/build.gradle @@ -70,7 +70,7 @@ modrinth { curseforge { apiKey = System.getenv("CURSEFORGE_TOKEN") ?: "" project { - id = "827288" + id = "1150314" changelogType = "markdown" changelog = "Release notes:\nhttps://github.com/NikitaCartes/Glowing-Eyeblossom/releases/tag/${project.version}" releaseType = "release" @@ -80,11 +80,10 @@ curseforge { addGameVersion("Java 21") - addGameVersion("1.21.2") - addGameVersion("1.21.3") + addGameVersion("1.21.4") mainArtifact(remapJar) { - displayName = "[1.21.2, 1.21.3] ${project.version}" + displayName = "[1.21.4] ${project.version}" } } options { diff --git a/gradle.properties b/gradle.properties index 566a98a..10ef492 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,9 @@ mod_name=Glowing Eyeblossom mod_id=glowing-eyeblossom -mod_version=1.2.0 +mod_version=1.3.0 -minecraft_version=1.21.4-rc1 -yarn_mappings=1.21.4-rc1+build.1 +minecraft_version=1.21.4 +yarn_mappings=1.21.4+build.1 loader_version=0.16.9 hocon_version=4.1.2 diff --git a/src/main/java/xyz/nikitacartes/glowingeyeblossom/config/ConfigTemplate.java b/src/main/java/xyz/nikitacartes/glowingeyeblossom/config/ConfigTemplate.java index a8e0984..74402b5 100644 --- a/src/main/java/xyz/nikitacartes/glowingeyeblossom/config/ConfigTemplate.java +++ b/src/main/java/xyz/nikitacartes/glowingeyeblossom/config/ConfigTemplate.java @@ -15,12 +15,13 @@ public abstract class ConfigTemplate { private transient final Pattern pattern = Pattern.compile("^[^$\"{}\\[\\]:=,+#`^?!@*&\\\\\\s/]+"); - transient final String configPath; + transient final String configFilePath; + transient final String configResourcePath = "xyz/nikitacartes/glowingeyeblossom/config/"; public static Path gameDirectory = FabricLoader.getInstance().getGameDir(); private static String modName = "GlowingEyeblossom"; - ConfigTemplate(String configPath) { - this.configPath = configPath; + ConfigTemplate(String configFilePath) { + this.configFilePath = configFilePath; } public static Config loadConfig(Class configClass, String configPath) { @@ -30,7 +31,8 @@ public static Config loadConfig(Class co try { return loader.load().get(configClass); } catch (ConfigurateException e) { - throw new RuntimeException("[" + modName + "] Failed to load config file", e); + System.err.println("[" + modName + "] Failed to load config file" + e); + return null; } } else { return null; @@ -46,7 +48,7 @@ public void save() { System.err.println("Failed to create config directory" + e); } } - Path path = gameDirectory.resolve("config/" + modName + "/" + configPath); + Path path = gameDirectory.resolve("config/" + modName + "/" + configFilePath); try { Files.writeString(path, handleTemplate()); } catch (IOException e) { diff --git a/src/main/java/xyz/nikitacartes/glowingeyeblossom/config/MainConfigV1.java b/src/main/java/xyz/nikitacartes/glowingeyeblossom/config/MainConfigV1.java index 44789cb..2bec3ed 100644 --- a/src/main/java/xyz/nikitacartes/glowingeyeblossom/config/MainConfigV1.java +++ b/src/main/java/xyz/nikitacartes/glowingeyeblossom/config/MainConfigV1.java @@ -25,7 +25,7 @@ public MainConfigV1() { } public static MainConfigV1 load() { - MainConfigV1 config = loadConfig(MainConfigV1.class, "main.conf"); + MainConfigV1 config = loadConfig(xyz.nikitacartes.glowingeyeblossom.config.MainConfigV1.class, "main.conf"); if (config == null) { config = new MainConfigV1(); config.save(); @@ -40,7 +40,7 @@ protected String handleTemplate() throws IOException { configValues.put("openEyeblossomFlowerpotBrightness", wrapIfNecessary(openEyeblossomFlowerpotBrightness)); configValues.put("closedEyeblossomFlowerpotBrightness", wrapIfNecessary(closedEyeblossomFlowerpotBrightness)); configValues.put("configVersion", wrapIfNecessary(configVersion)); - String configTemplate = Resources.toString(getResource("config/" + configPath), UTF_8); + String configTemplate = Resources.toString(getResource( configResourcePath + configFilePath), UTF_8); return new StringSubstitutor(configValues).replace(configTemplate); } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 730d2ec..df2b901 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -20,7 +20,7 @@ ], "depends": { "fabricloader": "*", - "minecraft": ">=1.21.2-", + "minecraft": ">=1.21.4-", "java": ">=21" } } \ No newline at end of file diff --git a/src/main/resources/config/main.conf b/src/main/resources/xyz/nikitacartes/glowingeyeblossom/config/main.conf similarity index 100% rename from src/main/resources/config/main.conf rename to src/main/resources/xyz/nikitacartes/glowingeyeblossom/config/main.conf