Use Codecs for adventure Component conversions & network serialization (#10014)

* finish implementing all adventure components in codecs

* add some initial tests

* Add round trip tests for text and translatable components

* Add more round trip test data (score component is failing)

* Add more round trip test data

* Fix SCORE_COMPONENT_MAP_CODEC

* Improve test failure messages

* Add failure cases

* Add a couple more test data

* Make use of AdventureCodecs

* Update patches after rebase

* Squash changes into adventure patch

* Fix AT formatting

* update comment

---------

Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
This commit is contained in:
Jake Potrebic 2023-12-11 22:02:06 -08:00 committed by GitHub
parent 82f9280ae4
commit 7c2dc4b342
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
637 changed files with 965 additions and 421 deletions

View file

@ -206,10 +206,10 @@ index 0000000000000000000000000000000000000000..8f07539a82f449ad217e316a7513a170
+
+}
diff --git a/src/main/java/io/papermc/paper/adventure/PaperAdventure.java b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
index 3dc613116c086444ece88bcb0a569eeea953074f..db54a9c32578defa02fa58dc694c96684a4885ac 100644
index 1fb9b0ea9f2dbff12d8d2fbc2ad2f4d88ca9f7ad..66ff48a12c8322cfbfd17c470d03dad1f912d123 100644
--- a/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
+++ b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
@@ -20,6 +20,7 @@ import net.kyori.adventure.text.TranslatableComponent;
@@ -22,6 +22,7 @@ import net.kyori.adventure.text.TranslatableComponent;
import net.kyori.adventure.text.flattener.ComponentFlattener;
import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.serializer.ComponentSerializer;
@ -217,14 +217,12 @@ index 3dc613116c086444ece88bcb0a569eeea953074f..db54a9c32578defa02fa58dc694c9668
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
@@ -107,6 +108,9 @@ public final class PaperAdventure {
@@ -109,6 +110,7 @@ public final class PaperAdventure {
public static final AttributeKey<Locale> LOCALE_ATTRIBUTE = AttributeKey.valueOf("adventure:locale"); // init after FLATTENER because classloading triggered here might create a logger
@Deprecated
public static final PlainComponentSerializer PLAIN = PlainComponentSerializer.builder().flattener(FLATTENER).build();
+
+ public static final ANSIComponentSerializer ANSI_SERIALIZER = ANSIComponentSerializer.builder().flattener(FLATTENER).build();
+
private static final Codec<CompoundTag, String, IOException, IOException> NBT_CODEC = new Codec<CompoundTag, String, IOException, IOException>() {
static final Codec<CompoundTag, String, IOException, IOException> NBT_CODEC = new Codec<CompoundTag, String, IOException, IOException>() {
@Override
public @NotNull CompoundTag decode(final @NotNull String encoded) throws IOException {
diff --git a/src/main/java/io/papermc/paper/adventure/providers/ComponentLoggerProviderImpl.java b/src/main/java/io/papermc/paper/adventure/providers/ComponentLoggerProviderImpl.java