From 8e871314efad46801dbad7b5d68fcc81a42ccfba Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Tue, 5 Dec 2023 20:56:02 -0800 Subject: [PATCH] fix serializing TextColor with name --- .../server/initial-work-on-native-Adventure-codecs.patch | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/patches/server/initial-work-on-native-Adventure-codecs.patch b/patches/server/initial-work-on-native-Adventure-codecs.patch index ef1a08a374..46593136d8 100644 --- a/patches/server/initial-work-on-native-Adventure-codecs.patch +++ b/patches/server/initial-work-on-native-Adventure-codecs.patch @@ -73,7 +73,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + final @Nullable NamedTextColor value = NamedTextColor.NAMES.value(s); + return value != null ? DataResult.success(value) : DataResult.error(() -> "Cannot convert " + s + " to adventure NamedTextColor"); + } -+ }, TextColor::asHexString); ++ }, textColor -> { ++ if (textColor instanceof NamedTextColor named) { ++ return NamedTextColor.NAMES.keyOrThrow(named); ++ } else { ++ return textColor.asHexString(); ++ } ++ }); + + private static final Codec KEY_CODEC = Codec.STRING.comapFlatMap(s -> { + return Key.parseable(s) ? DataResult.success(Key.key(s)) : DataResult.error(() -> "Cannot convert " + s + " to adventure Key");