From 98f29ec5c30d23999fce37d7daf7aba8f10f25d3 Mon Sep 17 00:00:00 2001 From: isXander Date: Wed, 16 Aug 2023 12:56:15 +0100 Subject: Add @OverrideName and @OverrideFormat --- .../java/dev/isxander/yacl3/api/controller/ControllerBuilder.java | 1 + .../isxander/yacl3/api/controller/ValueFormattableController.java | 7 ++++++- .../java/dev/isxander/yacl3/api/controller/ValueFormatter.java | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 common/src/main/java/dev/isxander/yacl3/api/controller/ValueFormatter.java (limited to 'common/src/main/java/dev/isxander/yacl3/api/controller') diff --git a/common/src/main/java/dev/isxander/yacl3/api/controller/ControllerBuilder.java b/common/src/main/java/dev/isxander/yacl3/api/controller/ControllerBuilder.java index 0cd3a55..bbd49a7 100644 --- a/common/src/main/java/dev/isxander/yacl3/api/controller/ControllerBuilder.java +++ b/common/src/main/java/dev/isxander/yacl3/api/controller/ControllerBuilder.java @@ -3,6 +3,7 @@ package dev.isxander.yacl3.api.controller; import dev.isxander.yacl3.api.Controller; import org.jetbrains.annotations.ApiStatus; +@FunctionalInterface public interface ControllerBuilder { @ApiStatus.Internal Controller build(); diff --git a/common/src/main/java/dev/isxander/yacl3/api/controller/ValueFormattableController.java b/common/src/main/java/dev/isxander/yacl3/api/controller/ValueFormattableController.java index af55e55..b886318 100644 --- a/common/src/main/java/dev/isxander/yacl3/api/controller/ValueFormattableController.java +++ b/common/src/main/java/dev/isxander/yacl3/api/controller/ValueFormattableController.java @@ -5,5 +5,10 @@ import net.minecraft.network.chat.Component; import java.util.function.Function; public interface ValueFormattableController> extends ControllerBuilder { - B valueFormatter(Function formatter); + B formatValue(ValueFormatter formatter); + + @Deprecated + default B valueFormatter(Function formatter) { + return formatValue(formatter::apply); + } } diff --git a/common/src/main/java/dev/isxander/yacl3/api/controller/ValueFormatter.java b/common/src/main/java/dev/isxander/yacl3/api/controller/ValueFormatter.java new file mode 100644 index 0000000..aecaf65 --- /dev/null +++ b/common/src/main/java/dev/isxander/yacl3/api/controller/ValueFormatter.java @@ -0,0 +1,7 @@ +package dev.isxander.yacl3.api.controller; + +import net.minecraft.network.chat.Component; + +public interface ValueFormatter { + Component format(T value); +} -- cgit