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:
parent
436a966767
commit
8e871314ef
1 changed files with 7 additions and 1 deletions
|
@ -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");
|
||||
|
|
Loading…
Add table
Reference in a new issue