diff options
author | isXander <xander@isxander.dev> | 2023-05-29 07:41:20 +0100 |
---|---|---|
committer | isXander <xander@isxander.dev> | 2023-05-29 07:41:20 +0100 |
commit | cb0d24d0fdcdd86587f06fd8683a73995daefed6 (patch) | |
tree | 6e5a30f5aa21f3e99ea145f967fd5eaa0dea7e49 /common/src/main | |
parent | b4344763d905030dbcb840eefc361bbdb3729d99 (diff) | |
download | YetAnotherConfigLib-cb0d24d0fdcdd86587f06fd8683a73995daefed6.tar.gz YetAnotherConfigLib-cb0d24d0fdcdd86587f06fd8683a73995daefed6.tar.bz2 YetAnotherConfigLib-cb0d24d0fdcdd86587f06fd8683a73995daefed6.zip |
Fix ListOption still using old controller system
Diffstat (limited to 'common/src/main')
-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; |