aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/config/elements/BasicOption.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/config/elements/BasicOption.java')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/elements/BasicOption.java12
1 files changed, 11 insertions, 1 deletions
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 86b339b..e3b3b16 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/elements/BasicOption.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/elements/BasicOption.java
@@ -2,6 +2,7 @@ package cc.polyfrost.oneconfig.config.elements;
import java.lang.reflect.Field;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.function.Supplier;
@SuppressWarnings({"unused"})
@@ -16,6 +17,8 @@ public abstract class BasicOption {
private final ArrayList<Runnable> listeners = new ArrayList<>();
private final ArrayList<Supplier<Boolean>> hideConditions = new ArrayList<>();
+ private static final HashMap<Field, BasicOption> options = new HashMap<>();
+
/**
* Initialize option
*
@@ -31,7 +34,10 @@ public abstract class BasicOption {
this.size = size;
this.category = category;
this.subcategory = subcategory;
- if (field != null) field.setAccessible(true);
+ if (field != null) {
+ field.setAccessible(true);
+ options.put(field, this);
+ }
}
/**
@@ -128,4 +134,8 @@ public abstract class BasicOption {
public void addHideCondition(Supplier<Boolean> supplier) {
this.hideConditions.add(supplier);
}
+
+ public static BasicOption getOption(Field field) {
+ return options.get(field);
+ }
}