From bd51b02576a1ea90089e498c57ca0d0595771949 Mon Sep 17 00:00:00 2001 From: 96DarkCode96 <96darkcode96@gmail.com> Date: Tue, 24 Dec 2024 15:49:13 +0100 Subject: [PATCH] Changed order of shadow_color in Codec; Used xmap instead of comapFlatMap --- .../io/papermc/paper/adventure/AdventureCodecs.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java b/paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java index 85fc3b5c6e..af71050196 100644 --- a/paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java +++ b/paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java @@ -79,10 +79,7 @@ public final class AdventureCodecs { public static final Codec COMPONENT_CODEC = recursive("adventure Component", AdventureCodecs::createCodec); public static final StreamCodec STREAM_COMPONENT_CODEC = ByteBufCodecs.fromCodecWithRegistriesTrusted(COMPONENT_CODEC); - static final Codec SHADOW_COLOR_CODEC = Codec.INT.comapFlatMap(s -> { - @Nullable ShadowColor value = ShadowColor.shadowColor(s); - return value != null ? DataResult.success(value) : DataResult.error(() -> "Cannot convert " + s + " to adventure ShadowColor"); - }, ShadowColor::value); + static final Codec SHADOW_COLOR_CODEC = Codec.INT.xmap(ShadowColor::shadowColor, ShadowColor::value); static final Codec TEXT_COLOR_CODEC = Codec.STRING.comapFlatMap(s -> { if (s.startsWith("#")) { @@ -225,6 +222,7 @@ public final class AdventureCodecs { public static final MapCodec