aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/config/profiles/Profiles.java
diff options
context:
space:
mode:
authorWyvest <45589059+Wyvest@users.noreply.github.com>2022-07-02 06:12:23 +0700
committerWyvest <45589059+Wyvest@users.noreply.github.com>2022-07-02 06:12:23 +0700
commitd4bb5a94308d4379ef3d6cc7b9221ea0d98ff051 (patch)
tree9bb9b53e2823f73084780673763504f4098bae69 /src/main/java/cc/polyfrost/oneconfig/config/profiles/Profiles.java
parentd2b1d57120bb51e76191302a58d935afe52b89df (diff)
downloadOneConfig-d4bb5a94308d4379ef3d6cc7b9221ea0d98ff051.tar.gz
OneConfig-d4bb5a94308d4379ef3d6cc7b9221ea0d98ff051.tar.bz2
OneConfig-d4bb5a94308d4379ef3d6cc7b9221ea0d98ff051.zip
Separate Minecraft dependant and non-dependant code
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/config/profiles/Profiles.java')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/profiles/Profiles.java16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/profiles/Profiles.java b/src/main/java/cc/polyfrost/oneconfig/config/profiles/Profiles.java
index 0f5ce09..29a9daa 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/profiles/Profiles.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/profiles/Profiles.java
@@ -1,9 +1,10 @@
package cc.polyfrost.oneconfig.config.profiles;
-import cc.polyfrost.oneconfig.internal.OneConfig;
import cc.polyfrost.oneconfig.internal.config.OneConfigConfig;
import cc.polyfrost.oneconfig.internal.config.core.ConfigCore;
import org.apache.commons.io.FileUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import java.io.File;
import java.io.IOException;
@@ -11,13 +12,14 @@ import java.util.ArrayList;
import java.util.Arrays;
public class Profiles {
+ private static final Logger LOGGER = LogManager.getLogger("OneConfig Profiles");
public static final File nonProfileSpecificDir = new File("OneConfig/config");
public static final File profileDir = new File("OneConfig/profiles");
public static ArrayList<String> profiles;
public static String getCurrentProfile() {
if (!profileDir.exists() && !profileDir.mkdir()) {
- OneConfig.LOGGER.fatal("Could not create profiles folder");
+ LOGGER.fatal("Could not create profiles folder");
return null;
}
if (profiles == null) {
@@ -33,7 +35,7 @@ public class Profiles {
public static void createProfile(String name) {
File folder = new File(profileDir, name);
if (!folder.exists() && !folder.mkdir()) {
- OneConfig.LOGGER.fatal("Could not create profile folder");
+ LOGGER.fatal("Could not create profile folder");
return;
}
profiles.add(name);
@@ -58,7 +60,7 @@ public class Profiles {
public static void loadProfile(String profile) {
ConfigCore.saveAll();
OneConfigConfig.currentProfile = profile;
- OneConfig.config.save();
+ //OneConfig.config.save(); todo do we actually need this
ConfigCore.reInitAll();
}
@@ -70,14 +72,14 @@ public class Profiles {
profiles.remove(name);
profiles.add(newName);
} catch (IOException e) {
- OneConfig.LOGGER.error("Failed to rename profile");
+ LOGGER.error("Failed to rename profile");
}
}
public static void deleteProfile(String name) {
if (name.equals(getCurrentProfile())) {
if (profiles.size() == 1) {
- OneConfig.LOGGER.error("Cannot delete only profile!");
+ LOGGER.error("Cannot delete only profile!");
return;
}
loadProfile(profiles.stream().filter(entry -> !entry.equals(name)).findFirst().get());
@@ -86,7 +88,7 @@ public class Profiles {
FileUtils.deleteDirectory(getProfileDir(name));
profiles.remove(name);
} catch (IOException e) {
- OneConfig.LOGGER.error("Failed to delete profile");
+ LOGGER.error("Failed to delete profile");
}
}
}