Skip to content

Commit

Permalink
Fix loading wrong config
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaCartes committed Dec 29, 2024
1 parent dce0e75 commit 76abc2f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
7 changes: 3 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 extends ConfigTemplate> Config loadConfig(Class<Config> configClass, String configPath) {
Expand All @@ -30,7 +31,8 @@ public static <Config extends ConfigTemplate> Config loadConfig(Class<Config> 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;
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}
}
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
],
"depends": {
"fabricloader": "*",
"minecraft": ">=1.21.2-",
"minecraft": ">=1.21.4-",
"java": ">=21"
}
}
File renamed without changes.

0 comments on commit 76abc2f

Please sign in to comment.