aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/isxander/yacl3/api/Option.java
diff options
context:
space:
mode:
authorisXander <xander@isxander.dev>2024-10-19 19:22:45 +0100
committerisXander <xander@isxander.dev>2024-10-19 19:22:45 +0100
commite73a08e6672fb380cab8db71340158969c5ef56b (patch)
treedd08a311f4eff9a91b465ef1854caa1286fc6f9a /src/main/java/dev/isxander/yacl3/api/Option.java
parent519ac2fc0e23587defcf4a8259979961d35d0ce2 (diff)
downloadYetAnotherConfigLib-e73a08e6672fb380cab8db71340158969c5ef56b.tar.gz
YetAnotherConfigLib-e73a08e6672fb380cab8db71340158969c5ef56b.tar.bz2
YetAnotherConfigLib-e73a08e6672fb380cab8db71340158969c5ef56b.zip
3.6.0
Diffstat (limited to 'src/main/java/dev/isxander/yacl3/api/Option.java')
-rw-r--r--src/main/java/dev/isxander/yacl3/api/Option.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/main/java/dev/isxander/yacl3/api/Option.java b/src/main/java/dev/isxander/yacl3/api/Option.java
index 38bd8ca..9190168 100644
--- a/src/main/java/dev/isxander/yacl3/api/Option.java
+++ b/src/main/java/dev/isxander/yacl3/api/Option.java
@@ -34,12 +34,15 @@ public interface Option<T> {
*/
@NotNull Controller<T> controller();
+ @NotNull StateManager<T> stateManager();
+
/**
* Binding for the option.
* Controls setting, getting and default value.
*
* @see Binding
*/
+ @Deprecated
@NotNull Binding<T> binding();
/**
@@ -101,9 +104,12 @@ public interface Option<T> {
return true;
}
+ void addEventListener(OptionEventListener<T> listener);
+
/**
* Adds a listener for when the pending value changes
*/
+ @Deprecated
void addListener(BiConsumer<Option<T>, T> changedListener);
static <T> Builder<T> createBuilder() {
@@ -146,6 +152,10 @@ public interface Option<T> {
*/
Builder<T> description(@NotNull Function<T, OptionDescription> descriptionFunction);
+ /**
+ * Supplies a controller for this option. A controller is the GUI control to interact with the option.
+ * @return this builder
+ */
Builder<T> controller(@NotNull Function<Option<T>, ControllerBuilder<T>> controllerBuilder);
/**
@@ -156,9 +166,12 @@ public interface Option<T> {
*/
Builder<T> customController(@NotNull Function<Option<T>, Controller<T>> control);
+ Builder<T> stateManager(@NotNull StateManager<T> stateManager);
+
/**
* Sets the binding for the option.
* Used for default, getter and setter.
+ * Under-the-hood, this creates a state manager that is individual to the option, sharing state with no options.
*
* @see Binding
*/
@@ -196,12 +209,17 @@ public interface Option<T> {
*/
Builder<T> flags(@NotNull Collection<? extends OptionFlag> flags);
+ Builder<T> addListener(@NotNull OptionEventListener<T> listener);
+
+ Builder<T> addListeners(@NotNull Collection<OptionEventListener<T>> listeners);
+
/**
* Instantly invokes the binder's setter when modified in the GUI.
* Prevents the user from undoing the change
* <p>
* Does not support {@link Option#flags()}!
*/
+ @Deprecated
Builder<T> instant(boolean instant);
/**
@@ -209,6 +227,7 @@ public interface Option<T> {
*
* @see Option#addListener(BiConsumer)
*/
+ @Deprecated
Builder<T> listener(@NotNull BiConsumer<Option<T>, T> listener);
/**
@@ -216,6 +235,7 @@ public interface Option<T> {
*
* @see Option#addListener(BiConsumer)
*/
+ @Deprecated
Builder<T> listeners(@NotNull Collection<BiConsumer<Option<T>, T>> listeners);
Option<T> build();