compile fixes
This commit is contained in:
parent
820f999ba4
commit
ca9001a936
17 changed files with 119 additions and 148 deletions
|
@ -1620,18 +1620,17 @@ index 0000000000000000000000000000000000000000..94a0a5850c97df08019c5b0f5d4e02a9
|
|||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/adventure/WrapperAwareSerializer.java b/src/main/java/io/papermc/paper/adventure/WrapperAwareSerializer.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0a7764797b0f1f346fb35f09377d5639bc382bff
|
||||
index 0000000000000000000000000000000000000000..c7da1c8395244803872601bb95de95ad91c93e29
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/adventure/WrapperAwareSerializer.java
|
||||
@@ -0,0 +1,39 @@
|
||||
@@ -0,0 +1,30 @@
|
||||
+package io.papermc.paper.adventure;
|
||||
+
|
||||
+import com.mojang.datafixers.util.Pair;
|
||||
+import java.util.function.Function;
|
||||
+import com.mojang.serialization.JavaOps;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.kyori.adventure.text.serializer.ComponentSerializer;
|
||||
+import net.minecraft.network.chat.ComponentSerialization;
|
||||
+import net.minecraft.util.JavaOps;
|
||||
+
|
||||
+final class WrapperAwareSerializer implements ComponentSerializer<Component, Component, net.minecraft.network.chat.Component> {
|
||||
+ @Override
|
||||
|
@ -1640,26 +1639,18 @@ index 0000000000000000000000000000000000000000..0a7764797b0f1f346fb35f09377d5639
|
|||
+ return ((AdventureComponent) input).adventure;
|
||||
+ }
|
||||
+ final Object obj = ComponentSerialization.CODEC.encodeStart(JavaOps.INSTANCE, input)
|
||||
+ .get().map(Function.identity(), partial -> {
|
||||
+ throw new RuntimeException("Failed to encode Minecraft Component: " + input + "; " + partial.message());
|
||||
+ });
|
||||
+ .getOrThrow(s -> new RuntimeException("Failed to encode Minecraft Component: " + input + "; " + s));
|
||||
+ final Pair<Component, Object> converted = AdventureCodecs.COMPONENT_CODEC.decode(JavaOps.INSTANCE, obj)
|
||||
+ .get().map(Function.identity(), partial -> {
|
||||
+ throw new RuntimeException("Failed to decode to adventure Component: " + obj + "; " + partial.message());
|
||||
+ });
|
||||
+ .getOrThrow(s -> new RuntimeException("Failed to decode to adventure Component: " + obj + "; " + s));
|
||||
+ return converted.getFirst();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public net.minecraft.network.chat.Component serialize(final Component component) {
|
||||
+ final Object obj = AdventureCodecs.COMPONENT_CODEC.encodeStart(JavaOps.INSTANCE, component)
|
||||
+ .get().map(Function.identity(), partial -> {
|
||||
+ throw new RuntimeException("Failed to encode adventure Component: " + component + "; " + partial.message());
|
||||
+ });
|
||||
+ .getOrThrow(s -> new RuntimeException("Failed to encode adventure Component: " + component + "; " + s));
|
||||
+ final Pair<net.minecraft.network.chat.Component, Object> converted = ComponentSerialization.CODEC.decode(JavaOps.INSTANCE, obj)
|
||||
+ .get().map(Function.identity(), partial -> {
|
||||
+ throw new RuntimeException("Failed to decode to Minecraft Component: " + obj + "; " + partial.message());
|
||||
+ });
|
||||
+ .getOrThrow(s -> new RuntimeException("Failed to decode to Minecraft Component: " + obj + "; " + s));
|
||||
+ return converted.getFirst();
|
||||
+ }
|
||||
+}
|
||||
|
@ -5598,10 +5589,10 @@ index 0000000000000000000000000000000000000000..3aedd0bbc97edacc1ebf71264b310e55
|
|||
+}
|
||||
diff --git a/src/test/java/io/papermc/paper/adventure/AdventureCodecsTest.java b/src/test/java/io/papermc/paper/adventure/AdventureCodecsTest.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..fdf9f95d6c65ba13108352c83d793b3a2126d69b
|
||||
index 0000000000000000000000000000000000000000..ff9e3013e4f5049c6cfa35803676516dfe8b9af1
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/io/papermc/paper/adventure/AdventureCodecsTest.java
|
||||
@@ -0,0 +1,402 @@
|
||||
@@ -0,0 +1,399 @@
|
||||
+package io.papermc.paper.adventure;
|
||||
+
|
||||
+import com.mojang.datafixers.util.Pair;
|
||||
|
@ -5854,10 +5845,7 @@ index 0000000000000000000000000000000000000000..fdf9f95d6c65ba13108352c83d793b3a
|
|||
+ }
|
||||
+
|
||||
+ static <R> R require(final DataResult<R> result, final Function<String, String> errorMessage) {
|
||||
+ return switch (result) {
|
||||
+ case final DataResult.Error<R> error -> throw new RuntimeException(errorMessage.apply(error.message()));
|
||||
+ case final DataResult.Success<R> success -> success.value();
|
||||
+ };
|
||||
+ return result.getOrThrow(s -> new RuntimeException(errorMessage.apply(s)));
|
||||
+ }
|
||||
+
|
||||
+ static List<Tag> invalidData() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue