Skip to content

Commit

Permalink
create config file for fabric if it doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
way2muchnoise committed Oct 27, 2024
1 parent 794e535 commit 7d961a2
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@
public class ConfigFileHandler {
public static void readFromConfig() {
JsonObject root = new JsonObject();
try (FileReader file = new FileReader(getConfigFile())) {
root = JsonParser.parseReader(file).getAsJsonObject();
try {
File configFile = getConfigFile();
if (!configFile.exists()) {
writeToConfig();
configFile = getConfigFile();
}
root = JsonParser.parseReader(new FileReader(configFile)).getAsJsonObject();
} catch (IOException e) {
Constants.log.error(e);
}
Expand Down Expand Up @@ -106,7 +111,7 @@ public static void writeToConfig() {
}
}

public static File getConfigFile() {
public static File getConfigFile() throws IOException {
return FabricLoader.getInstance().getConfigDir().resolve("betteradvancements.json").toFile();
}
}

0 comments on commit 7d961a2

Please sign in to comment.