diff --git a/src/main/java/net/szum123321/textile_backup/ConfigHandler.java b/src/main/java/net/szum123321/textile_backup/ConfigHandler.java index dad10c3..2a19c0c 100644 --- a/src/main/java/net/szum123321/textile_backup/ConfigHandler.java +++ b/src/main/java/net/szum123321/textile_backup/ConfigHandler.java @@ -21,6 +21,7 @@ package net.szum123321.textile_backup; import blue.endless.jankson.Comment; import io.github.cottonmc.cotton.config.annotations.ConfigFile; +import java.io.File; import java.time.format.DateTimeFormatter; import java.util.HashSet; import java.util.Optional; @@ -108,6 +109,16 @@ public class ConfigHandler { return Optional.of("dateTimeFormat is wrong!\n" + e.getMessage() + "\n See: https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html"); } + File path = new File(Statics.CONFIG.path).getAbsoluteFile(); + + if (!path.exists()) { + try { + path.mkdirs(); + } catch (Exception e) { + return Optional.of("Something went wrong while creating backup folder!\n" + e.getMessage()); + } + } + return Optional.empty(); } diff --git a/src/main/java/net/szum123321/textile_backup/core/Utilities.java b/src/main/java/net/szum123321/textile_backup/core/Utilities.java index dec4b1c..cf0e8d5 100644 --- a/src/main/java/net/szum123321/textile_backup/core/Utilities.java +++ b/src/main/java/net/szum123321/textile_backup/core/Utilities.java @@ -134,18 +134,7 @@ public class Utilities { path = path.toPath().resolve(worldName).toFile(); if (!path.exists()) { - try { - path.mkdirs(); - } catch (Exception e) { - Statics.LOGGER.error("An exception occurred!", e); - - return FabricLoader - .getInstance() - .getGameDirectory() - .toPath() - .resolve(Statics.CONFIG.path) - .toFile(); - } + path.mkdirs(); } return path;