aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/config/elements/BasicOption.java
diff options
context:
space:
mode:
authorWyvest <45589059+Wyvest@users.noreply.github.com>2022-06-29 16:10:18 +0700
committerWyvest <45589059+Wyvest@users.noreply.github.com>2022-06-29 16:10:43 +0700
commit975826256806e19306987e05aa0e59f70d09b0b1 (patch)
treede3f33b41cd63774b92c4075a051b12a4cb2d4d5 /src/main/java/cc/polyfrost/oneconfig/config/elements/BasicOption.java
parentd4c12a8786597a38fe1a8e31b5be3835dffbb0c6 (diff)
downloadOneConfig-975826256806e19306987e05aa0e59f70d09b0b1.tar.gz
OneConfig-975826256806e19306987e05aa0e59f70d09b0b1.tar.bz2
OneConfig-975826256806e19306987e05aa0e59f70d09b0b1.zip
unfinished stuff
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);
+ }
}