diff options
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/config')
5 files changed, 14 insertions, 23 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java b/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java index a518633..b46c65d 100644 --- a/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java +++ b/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java @@ -8,16 +8,16 @@ import java.io.*; import java.nio.charset.StandardCharsets; public class OneConfigConfig extends Config { + public static String currentProfile = "Default Profile"; + public OneConfigConfig() { super(null, "OneConfig.json"); } @Override public void init(ModData modData) { - if (new File("OneConfig/" + configFile).exists()) - load(); - else - save(); + if (new File("OneConfig/" + configFile).exists()) load(); + else save(); } @Override @@ -37,6 +37,4 @@ public class OneConfigConfig extends Config { e.printStackTrace(); } } - - public static String currentProfile = "Default Profile"; } diff --git a/src/main/java/io/polyfrost/oneconfig/config/core/ConfigCore.java b/src/main/java/io/polyfrost/oneconfig/config/core/ConfigCore.java index a66a8a0..9bb2e85 100644 --- a/src/main/java/io/polyfrost/oneconfig/config/core/ConfigCore.java +++ b/src/main/java/io/polyfrost/oneconfig/config/core/ConfigCore.java @@ -10,13 +10,13 @@ import java.util.HashMap; public class ConfigCore { public static HashMap<ModData, ArrayList<Option>> settings = new HashMap<>(); - public static void saveAll () { + public static void saveAll() { for (ModData modData : settings.keySet()) { modData.config.save(); } } - public static void reInitAll () { + public static void reInitAll() { ArrayList<ModData> data = new ArrayList<>(settings.keySet()); settings.clear(); HudCore.huds.clear(); diff --git a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java index 2e3e92d..73dbbe7 100644 --- a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java +++ b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java @@ -20,8 +20,7 @@ import java.util.Optional; public class Config { protected final String configFile; - protected final Gson gson = new GsonBuilder().excludeFieldsWithModifiers(Modifier.TRANSIENT).setPrettyPrinting() - .registerTypeAdapterFactory(OneConfigTypeAdapterFactory.getStaticTypeAdapterFactory()).create(); + protected final Gson gson = new GsonBuilder().excludeFieldsWithModifiers(Modifier.TRANSIENT).setPrettyPrinting().registerTypeAdapterFactory(OneConfigTypeAdapterFactory.getStaticTypeAdapterFactory()).create(); /** * @param modData information about the mod @@ -33,10 +32,8 @@ public class Config { } public void init(ModData modData) { - if (Profiles.getProfileFile(configFile).exists()) - load(); - else - save(); + if (Profiles.getProfileFile(configFile).exists()) load(); + else save(); modData.config = this; ConfigCore.settings.put(modData, generateOptionList(this.getClass())); } @@ -109,8 +106,7 @@ public class Config { } } else { Option customOption = processCustomOption(field); - if (customOption != null) - options.add(customOption); + if (customOption != null) options.add(customOption); } } return options; diff --git a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Option.java b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Option.java index 5980a63..99cf656 100644 --- a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Option.java +++ b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Option.java @@ -19,8 +19,7 @@ public abstract class Option { this.field = field; this.name = name; this.description = description; - if (field != null) - field.setAccessible(true); + if (field != null) field.setAccessible(true); } /** diff --git a/src/main/java/io/polyfrost/oneconfig/config/profiles/Profiles.java b/src/main/java/io/polyfrost/oneconfig/config/profiles/Profiles.java index db9fce2..45d448d 100644 --- a/src/main/java/io/polyfrost/oneconfig/config/profiles/Profiles.java +++ b/src/main/java/io/polyfrost/oneconfig/config/profiles/Profiles.java @@ -11,8 +11,8 @@ import java.util.ArrayList; import java.util.Arrays; public class Profiles { - public static ArrayList<String> profiles; private static final File profileDir = new File("OneConfig/profiles"); + public static ArrayList<String> profiles; public static String getCurrentProfile() { if (!profileDir.exists() && !profileDir.mkdir()) { @@ -21,8 +21,7 @@ public class Profiles { } if (profiles == null) { String[] profilesArray = new File("OneConfig/profiles").list((file, s) -> file.isDirectory()); - if (profilesArray != null) - profiles = new ArrayList<>(Arrays.asList(profilesArray)); + if (profilesArray != null) profiles = new ArrayList<>(Arrays.asList(profilesArray)); } if (!getProfileDir(OneConfigConfig.currentProfile).exists()) { createProfile(OneConfigConfig.currentProfile); @@ -62,8 +61,7 @@ public class Profiles { try { File newFile = new File(new File("OneConfig/profiles"), newName); FileUtils.moveDirectory(getProfileDir(name), newFile); - if (OneConfigConfig.currentProfile.equals(name)) - OneConfigConfig.currentProfile = newName; + if (OneConfigConfig.currentProfile.equals(name)) OneConfigConfig.currentProfile = newName; profiles.remove(name); profiles.add(newName); } catch (IOException e) { |