diff options
Diffstat (limited to 'common/src')
-rw-r--r-- | common/src/main/java/dev/isxander/yacl/api/ListOption.java | 5 | ||||
-rw-r--r-- | common/src/main/java/dev/isxander/yacl/impl/ListOptionImpl.java | 11 |
2 files changed, 14 insertions, 2 deletions
diff --git a/common/src/main/java/dev/isxander/yacl/api/ListOption.java b/common/src/main/java/dev/isxander/yacl/api/ListOption.java index 53d9119..e370f36 100644 --- a/common/src/main/java/dev/isxander/yacl/api/ListOption.java +++ b/common/src/main/java/dev/isxander/yacl/api/ListOption.java @@ -1,6 +1,7 @@ package dev.isxander.yacl.api; import com.google.common.collect.ImmutableList; +import dev.isxander.yacl.api.controller.ControllerBuilder; import dev.isxander.yacl.impl.ListOptionImpl; import net.minecraft.network.chat.Component; import org.jetbrains.annotations.ApiStatus; @@ -68,13 +69,15 @@ public interface ListOption<T> extends OptionGroup, Option<List<T>> { */ Builder<T> initial(@NotNull T initialValue); + Builder<T> controller(@NotNull Function<Option<T>, ControllerBuilder<T>> controller); + /** * Sets the controller for the option. * This is how you interact and change the options. * * @see dev.isxander.yacl.gui.controllers */ - Builder<T> controller(@NotNull Function<ListOptionEntry<T>, Controller<T>> control); + Builder<T> customController(@NotNull Function<ListOptionEntry<T>, Controller<T>> control); /** * Sets the binding for the option. diff --git a/common/src/main/java/dev/isxander/yacl/impl/ListOptionImpl.java b/common/src/main/java/dev/isxander/yacl/impl/ListOptionImpl.java index 015a7c3..e81d702 100644 --- a/common/src/main/java/dev/isxander/yacl/impl/ListOptionImpl.java +++ b/common/src/main/java/dev/isxander/yacl/impl/ListOptionImpl.java @@ -3,6 +3,7 @@ package dev.isxander.yacl.impl; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import dev.isxander.yacl.api.*; +import dev.isxander.yacl.api.controller.ControllerBuilder; import net.minecraft.network.chat.Component; import org.apache.commons.lang3.Validate; import org.jetbrains.annotations.ApiStatus; @@ -239,7 +240,15 @@ public final class ListOptionImpl<T> implements ListOption<T> { } @Override - public Builder<T> controller(@NotNull Function<ListOptionEntry<T>, Controller<T>> control) { + public Builder<T> controller(@NotNull Function<Option<T>, ControllerBuilder<T>> controller) { + Validate.notNull(controller, "`controller` cannot be null"); + + this.controllerFunction = opt -> controller.apply(opt).build(); + return this; + } + + @Override + public Builder<T> customController(@NotNull Function<ListOptionEntry<T>, Controller<T>> control) { Validate.notNull(control, "`control` cannot be null"); this.controllerFunction = control; |