Skip to content

Commit

Permalink
Fix #6, #7
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaCartes committed Dec 29, 2024
1 parent 1f8b442 commit 282dd6f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Also check out [Glowing Eyeblossom](https://github.com/NikitaCartes/Glowing-Eyeb
- Torchflower crop, big: 12

### Config
You can change the light level of the Eyeblossom in the config file.
You can change the light level of the Torchflower in the config file.
The config file is located in the `<game directory>/config/GlowingTorchflower/main.conf`.

![screenshot.png](screenshot.png)
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod_name=Glowing Torchflower
mod_id=glowing-torchflower
mod_version=1.2.0
mod_version=1.3.0

minecraft_version=1.21.2
yarn_mappings=1.21.2+build.1
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/glowingtorchflower/config/";
public static Path gameDirectory = FabricLoader.getInstance().getGameDir();
private static String modName = "GlowingTorchflower";

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 @@ -39,7 +39,7 @@ protected String handleTemplate() throws IOException {
configValues.put("torchflowerStage1Brightness", wrapIfNecessary(torchflowerStage1Brightness));
configValues.put("torchflowerStage2Brightness", wrapIfNecessary(torchflowerStage2Brightness));
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);
}
}
File renamed without changes.

0 comments on commit 282dd6f

Please sign in to comment.