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
parent 4580d97f5e
commit 6e3d7add28
4 changed files with 878 additions and 334 deletions

View file

@ -221,10 +221,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
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