Fix Cannot be adventure component serialized when the legacy component is null (#5754)

This commit is contained in:
LemonCaramel 2021-06-05 16:49:04 +09:00 committed by GitHub
parent afb0748a2c
commit 3673d6758e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -475,7 +475,7 @@ index 0000000000000000000000000000000000000000..caa9708f321f04cd02534161231c0599
+} +}
diff --git a/src/main/java/io/papermc/paper/adventure/PaperAdventure.java b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java diff --git a/src/main/java/io/papermc/paper/adventure/PaperAdventure.java b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..c60457e9240c33a4721b82a00cef081fb320c8a7 index 0000000000000000000000000000000000000000..7b14b3c2486f03778d4673cf9684aa576dc2724a
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java +++ b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
@@ -0,0 +1,344 @@ @@ -0,0 +1,344 @@
@ -606,7 +606,7 @@ index 0000000000000000000000000000000000000000..c60457e9240c33a4721b82a00cef081f
+ // Component + // Component
+ +
+ public static Component asAdventure(final IChatBaseComponent component) { + public static Component asAdventure(final IChatBaseComponent component) {
+ return GSON.serializer().fromJson(IChatBaseComponent.ChatSerializer.toJsonTree(component), Component.class); + return component == null ? Component.empty() : GSON.serializer().fromJson(IChatBaseComponent.ChatSerializer.toJsonTree(component), Component.class);
+ } + }
+ +
+ public static ArrayList<Component> asAdventure(final List<IChatBaseComponent> vanillas) { + public static ArrayList<Component> asAdventure(final List<IChatBaseComponent> vanillas) {