diff options
Diffstat (limited to 'src/main')
5 files changed, 9 insertions, 12 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/Config.java b/src/main/java/cc/polyfrost/oneconfig/config/Config.java index 37dcf18..88d0784 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/Config.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/Config.java @@ -33,7 +33,7 @@ import java.util.Optional; import java.util.function.Supplier; public class Config { - public static Config INSTANCE = null; + public transient static Config INSTANCE = null; public final transient HashMap<String, BasicOption> optionNames = new HashMap<>(); transient protected final String configFile; transient protected final Gson gson = new GsonBuilder().excludeFieldsWithModifiers(Modifier.TRANSIENT).setPrettyPrinting().create(); diff --git a/src/main/java/cc/polyfrost/oneconfig/config/core/ConfigUtils.java b/src/main/java/cc/polyfrost/oneconfig/config/core/ConfigUtils.java index 99b52e3..fb3ff3a 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/core/ConfigUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/core/ConfigUtils.java @@ -43,17 +43,16 @@ public class ConfigUtils { return null; } - public static ArrayList<BasicOption> getClassOptions(Object object, Class<?> parentClass) { + public static ArrayList<BasicOption> getClassOptions(Object object) { ArrayList<BasicOption> options = new ArrayList<>(); ArrayList<Field> fields = new ArrayList<>(Arrays.asList(object.getClass().getDeclaredFields())); + Class<?> parentClass = object.getClass(); Class<?> clazz = object.getClass(); while (true) { clazz = clazz.getSuperclass(); - if (clazz != null && clazz != parentClass) { - fields.addAll(Arrays.asList(clazz.getDeclaredFields())); - } else { - break; - } + if (clazz != null && clazz != parentClass) fields.addAll(Arrays.asList(clazz.getDeclaredFields())); + else break; + parentClass = clazz; } for (Field field : fields) { Option option = findAnnotation(field, Option.class); diff --git a/src/main/java/cc/polyfrost/oneconfig/config/elements/BasicOption.java b/src/main/java/cc/polyfrost/oneconfig/config/elements/BasicOption.java index 2bee982..eba2f9f 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/elements/BasicOption.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/elements/BasicOption.java @@ -37,9 +37,7 @@ public abstract class BasicOption { * @param object Java object to set the variable to */ protected void set(Object object) throws IllegalAccessException { - if (field == null) { - return; - } + if (field == null) return; field.set(parent, object); } diff --git a/src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java b/src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java index fb42e9c..e91a7ce 100644 --- a/src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java @@ -22,7 +22,7 @@ public class HUDUtils { try { options.add(new ConfigHeader(field, hud, hudAnnotation.name(), category, subcategory, 2)); options.add(new ConfigSwitch(hud.getClass().getField("enabled"), hud, "Enabled", category, subcategory, 2)); - options.addAll(ConfigUtils.getClassOptions(hud, Hud.class)); + options.addAll(ConfigUtils.getClassOptions(hud)); options.add(new ConfigCheckbox(hud.getClass().getField("rounded"), hud, "Rounded corners", category, subcategory, 1)); options.get(options.size() - 1).addDependency(() -> hud.enabled); options.add(new ConfigCheckbox(hud.getClass().getField("border"), hud, "Outline/border", category, subcategory, 1)); diff --git a/src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java b/src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java index 54b2728..2f4960e 100644 --- a/src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java +++ b/src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java @@ -42,7 +42,7 @@ public class TestConfig_Test extends Config { options = {"option1", "option2", "option3"}, size = OptionSize.DUAL ) - private int testDropdown = 0; + private static int testDropdown = 0; @Color( name = "Test Color", |