From 975826256806e19306987e05aa0e59f70d09b0b1 Mon Sep 17 00:00:00 2001 From: Wyvest <45589059+Wyvest@users.noreply.github.com> Date: Wed, 29 Jun 2022 16:10:18 +0700 Subject: unfinished stuff --- .../cc/polyfrost/oneconfig/config/elements/BasicOption.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/main/java/cc/polyfrost/oneconfig/config/elements') 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 listeners = new ArrayList<>(); private final ArrayList> hideConditions = new ArrayList<>(); + private static final HashMap 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 supplier) { this.hideConditions.add(supplier); } + + public static BasicOption getOption(Field field) { + return options.get(field); + } } -- cgit