aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/isxander/yacl3/impl/ButtonOptionImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/dev/isxander/yacl3/impl/ButtonOptionImpl.java')
-rw-r--r--src/main/java/dev/isxander/yacl3/impl/ButtonOptionImpl.java20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/main/java/dev/isxander/yacl3/impl/ButtonOptionImpl.java b/src/main/java/dev/isxander/yacl3/impl/ButtonOptionImpl.java
index 170b8e0..60a9dc9 100644
--- a/src/main/java/dev/isxander/yacl3/impl/ButtonOptionImpl.java
+++ b/src/main/java/dev/isxander/yacl3/impl/ButtonOptionImpl.java
@@ -17,10 +17,9 @@ import java.util.function.Consumer;
public final class ButtonOptionImpl implements ButtonOption {
private final Component name;
private final OptionDescription description;
- private final BiConsumer<YACLScreen, ButtonOption> action;
+ private final StateManager<BiConsumer<YACLScreen, ButtonOption>> stateManager;
private boolean available;
private final Controller<BiConsumer<YACLScreen, ButtonOption>> controller;
- private final Binding<BiConsumer<YACLScreen, ButtonOption>> binding;
public ButtonOptionImpl(
@NotNull Component name,
@@ -31,10 +30,9 @@ public final class ButtonOptionImpl implements ButtonOption {
) {
this.name = name;
this.description = description;
- this.action = action;
+ this.stateManager = StateManager.createImmutable(action);
this.available = available;
this.controller = text != null ? new ActionController(this, text) : new ActionController(this);
- this.binding = new EmptyBinderImpl();
}
@Override
@@ -54,7 +52,7 @@ public final class ButtonOptionImpl implements ButtonOption {
@Override
public BiConsumer<YACLScreen, ButtonOption> action() {
- return action;
+ return stateManager().get();
}
@Override
@@ -73,8 +71,13 @@ public final class ButtonOptionImpl implements ButtonOption {
}
@Override
+ public @NotNull StateManager<BiConsumer<YACLScreen, ButtonOption>> stateManager() {
+ return this.stateManager;
+ }
+
+ @Override
public @NotNull Binding<BiConsumer<YACLScreen, ButtonOption>> binding() {
- return binding;
+ return new EmptyBinderImpl();
}
@Override
@@ -118,6 +121,11 @@ public final class ButtonOptionImpl implements ButtonOption {
}
@Override
+ public void addEventListener(OptionEventListener<BiConsumer<YACLScreen, ButtonOption>> listener) {
+
+ }
+
+ @Override
public void addListener(BiConsumer<Option<BiConsumer<YACLScreen, ButtonOption>>, BiConsumer<YACLScreen, ButtonOption>> changedListener) {
}