1
0
Fork 0
mirror of https://github.com/PaperMC/Paper.git synced 2025-02-16 18:31:53 +01:00

fix serializing TextColor with name

This commit is contained in:
Jake Potrebic 2023-12-05 20:56:02 -08:00
parent 436a966767
commit 8e871314ef

View file

@ -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> KEY_CODEC = Codec.STRING.comapFlatMap(s -> {
+ return Key.parseable(s) ? DataResult.success(Key.key(s)) : DataResult.error(() -> "Cannot convert " + s + " to adventure Key");