aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-26 17:51:37 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-26 17:51:37 +0200
commita4b9ba9629f91009a4a0395f4bd18eee18aebf70 (patch)
tree5488729f3d3142c73a5e4f957a906b4e926cd9e9 /src/main
parentff402d657247441abd330f8c88a8a39d02f9491a (diff)
downloadOneConfig-a4b9ba9629f91009a4a0395f4bd18eee18aebf70.tar.gz
OneConfig-a4b9ba9629f91009a4a0395f4bd18eee18aebf70.tar.bz2
OneConfig-a4b9ba9629f91009a4a0395f4bd18eee18aebf70.zip
fix oopsies
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/Config.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/core/ConfigUtils.java11
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/elements/BasicOption.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java2
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",