From cb0d24d0fdcdd86587f06fd8683a73995daefed6 Mon Sep 17 00:00:00 2001 From: isXander Date: Mon, 29 May 2023 07:41:20 +0100 Subject: Fix ListOption still using old controller system --- common/src/main/java/dev/isxander/yacl/api/ListOption.java | 5 ++++- .../src/main/java/dev/isxander/yacl/impl/ListOptionImpl.java | 11 ++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'common/src/main') 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 extends OptionGroup, Option> { */ Builder initial(@NotNull T initialValue); + Builder controller(@NotNull Function, ControllerBuilder> controller); + /** * Sets the controller for the option. * This is how you interact and change the options. * * @see dev.isxander.yacl.gui.controllers */ - Builder controller(@NotNull Function, Controller> control); + Builder customController(@NotNull Function, Controller> 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 implements ListOption { } @Override - public Builder controller(@NotNull Function, Controller> control) { + public Builder controller(@NotNull Function, ControllerBuilder> controller) { + Validate.notNull(controller, "`controller` cannot be null"); + + this.controllerFunction = opt -> controller.apply(opt).build(); + return this; + } + + @Override + public Builder customController(@NotNull Function, Controller> control) { Validate.notNull(control, "`control` cannot be null"); this.controllerFunction = control; -- cgit