diff --git a/Fabric/src/main/java/betteradvancements/fabric/config/ConfigFileHandler.java b/Fabric/src/main/java/betteradvancements/fabric/config/ConfigFileHandler.java index 028e70a..9a861d8 100644 --- a/Fabric/src/main/java/betteradvancements/fabric/config/ConfigFileHandler.java +++ b/Fabric/src/main/java/betteradvancements/fabric/config/ConfigFileHandler.java @@ -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); } @@ -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(); } }