mirror of
https://github.com/PaperMC/Paper.git
synced 2025-07-31 04:02:06 -07:00
fix serializing TextColor with name
This commit is contained in:
@@ -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");
|
||||
|
Reference in New Issue
Block a user