aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/config/interfaces/BasicOption.java
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-05-12 19:07:05 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-05-12 19:07:05 +0200
commitd69ef45507c8073ae656b171bea23a3063f8250f (patch)
treefdaa1098555c7ced9c72fe5064c232d05125458a /src/main/java/cc/polyfrost/oneconfig/config/interfaces/BasicOption.java
parent174dcbf96f4715fe52a21ca8592d5d71b6fa4a8b (diff)
downloadOneConfig-d69ef45507c8073ae656b171bea23a3063f8250f.tar.gz
OneConfig-d69ef45507c8073ae656b171bea23a3063f8250f.tar.bz2
OneConfig-d69ef45507c8073ae656b171bea23a3063f8250f.zip
hud stuff
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/config/interfaces/BasicOption.java')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/interfaces/BasicOption.java15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/interfaces/BasicOption.java b/src/main/java/cc/polyfrost/oneconfig/config/interfaces/BasicOption.java
index c036408..6fa3254 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/interfaces/BasicOption.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/interfaces/BasicOption.java
@@ -9,16 +9,19 @@ public abstract class BasicOption {
protected final String name;
public final int size;
private Supplier<Boolean> dependency;
+ protected final Object parent;
/**
* Initialize option
*
- * @param field variable attached to option (null for category)
- * @param name name of option
- * @param size size of option, 0 for single column, 1 for double.
+ * @param field variable attached to option (null for category)
+ * @param parent the parent object of the field, used for getting and setting the variable
+ * @param name name of option
+ * @param size size of option, 0 for single column, 1 for double.
*/
- public BasicOption(Field field, String name, int size) {
+ public BasicOption(Field field, Object parent, String name, int size) {
this.field = field;
+ this.parent = parent;
this.name = name;
this.size = size;
if (field != null) field.setAccessible(true);
@@ -29,7 +32,7 @@ public abstract class BasicOption {
*/
protected void set(Object object) throws IllegalAccessException {
if (field == null) return;
- field.set(null, object);
+ field.set(parent, object);
}
/**
@@ -37,7 +40,7 @@ public abstract class BasicOption {
*/
protected Object get() throws IllegalAccessException {
if (field == null) return null;
- return field.get(null);
+ return field.get(parent);
}
/**