Skip to content

Commit e8c123d

Browse files
authored
Fix from 7d961a2 for ConfigFileHandler.java (#187)
Backported fix from 7d961a2 to the 1.20.1 branch
1 parent be0bf2e commit e8c123d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Fabric/src/main/java/betteradvancements/fabric/config/ConfigFileHandler.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@
2222
public class ConfigFileHandler {
2323
public static void readFromConfig() {
2424
JsonObject root = new JsonObject();
25-
try (FileReader file = new FileReader(getConfigFile())) {
26-
root = JsonParser.parseReader(file).getAsJsonObject();
25+
try {
26+
File configFile = getConfigFile();
27+
if (!configFile.exists()) {
28+
writeToConfig();
29+
configFile = getConfigFile();
30+
}
31+
root = JsonParser.parseReader(new FileReader(configFile)).getAsJsonObject();
2732
} catch (IOException e) {
2833
Constants.log.error(e);
2934
}
@@ -106,7 +111,7 @@ public static void writeToConfig() {
106111
}
107112
}
108113

109-
public static File getConfigFile() {
114+
public static File getConfigFile() throws IOException {
110115
return FabricLoader.getInstance().getConfigDir().resolve("betteradvancements.json").toFile();
111116
}
112117
}

0 commit comments

Comments
 (0)