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.java22
1 files changed, 16 insertions, 6 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 947156a..0408c0a 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/elements/BasicOption.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/elements/BasicOption.java
@@ -13,6 +13,7 @@ public abstract class BasicOption {
public final String category;
public final String subcategory;
private final ArrayList<Supplier<Boolean>> dependencies = new ArrayList<>();
+ private final ArrayList<Runnable> listeners = new ArrayList<>();
/**
* Initialize option
@@ -83,6 +84,16 @@ public abstract class BasicOption {
}
/**
+ * @return If the option is enabled, based on the dependencies
+ */
+ protected boolean isEnabled() {
+ for (Supplier<Boolean> dependency : dependencies) {
+ if (!dependency.get()) return false;
+ }
+ return true;
+ }
+
+ /**
* Add a condition to this option
*
* @param supplier The dependency
@@ -92,12 +103,11 @@ public abstract class BasicOption {
}
/**
- * @return If the option is enabled, based on the dependencies
+ * Add a listener to this option
+ *
+ * @param runnable The listener
*/
- protected boolean isEnabled() {
- for (Supplier<Boolean> dependency : dependencies) {
- if (!dependency.get()) return false;
- }
- return true;
+ public void addListener(Runnable runnable) {
+ this.listeners.add(runnable);
}
}