mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-03 14:57:35 +01:00
fix serializing TextColor with name
This commit is contained in:
parent
29e137669e
commit
cc78c7f5f5
@ -11,10 +11,10 @@ public net.minecraft.network.chat.contents.TranslatableContents filterAllowedArg
|
|||||||
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java b/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java
|
diff --git a/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java b/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..6f5a2bdf50de97e6180b42cf988c3e98385a99ee
|
index 0000000000000000000000000000000000000000..db13894e2710b933f69f3adaa7e728461e3cf049
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java
|
+++ b/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java
|
||||||
@@ -0,0 +1,271 @@
|
@@ -0,0 +1,277 @@
|
||||||
+package io.papermc.paper.adventure;
|
+package io.papermc.paper.adventure;
|
||||||
+
|
+
|
||||||
+import com.mojang.datafixers.util.Either;
|
+import com.mojang.datafixers.util.Either;
|
||||||
@ -73,7 +73,13 @@ index 0000000000000000000000000000000000000000..6f5a2bdf50de97e6180b42cf988c3e98
|
|||||||
+ final @Nullable NamedTextColor value = NamedTextColor.NAMES.value(s);
|
+ final @Nullable NamedTextColor value = NamedTextColor.NAMES.value(s);
|
||||||
+ return value != null ? DataResult.success(value) : DataResult.error(() -> "Cannot convert " + s + " to adventure NamedTextColor");
|
+ 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 -> {
|
+ 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");
|
+ return Key.parseable(s) ? DataResult.success(Key.key(s)) : DataResult.error(() -> "Cannot convert " + s + " to adventure Key");
|
||||||
|
Loading…
Reference in New Issue
Block a user