fix stupid legacy chat garbage

This commit is contained in:
Riley Park 2021-02-22 00:45:21 -08:00
parent a1eebfea96
commit 33d4f608ba
No known key found for this signature in database
GPG Key ID: D831AF236C834E45

View File

@ -8,7 +8,7 @@ Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
diff --git a/src/main/java/io/papermc/paper/adventure/AdventureComponent.java b/src/main/java/io/papermc/paper/adventure/AdventureComponent.java
new file mode 100644
index 0000000000000000000000000000000000000000..0d1ae6b32a2ccae1e097371b5e0d9ec662865c2f
index 0000000000000000000000000000000000000000..a2acd31dce4461338a8baa96e03df36a4b4281b8
--- /dev/null
+++ b/src/main/java/io/papermc/paper/adventure/AdventureComponent.java
@@ -0,0 +1,78 @@
@ -36,7 +36,7 @@ index 0000000000000000000000000000000000000000..0d1ae6b32a2ccae1e097371b5e0d9ec6
+ this.wrapped = wrapped;
+ }
+
+ IChatBaseComponent deepConverted() {
+ public IChatBaseComponent deepConverted() {
+ IChatBaseComponent converted = this.converted;
+ if (converted == null) {
+ converted = PaperAdventure.WRAPPER_AWARE_SERIALIZER.serialize(this.wrapped);
@ -2901,3 +2901,15 @@ index 0fba3d2a8d3bd7ec615d137e4625a7f357729d8d..b900aaf66f25e41956e7a4370b887fd4
@Override
public String getDisplayName() throws IllegalStateException {
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
index 1582a799e456402453c43c2e0c6b8a194951a9dd..0dfb9ddad426e962db1216d1f490c1c5e2210adf 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
@@ -290,6 +290,7 @@ public final class CraftChatMessage {
public static String fromComponent(IChatBaseComponent component) {
if (component == null) return "";
+ if (component instanceof io.papermc.paper.adventure.AdventureComponent) component = ((io.papermc.paper.adventure.AdventureComponent) component).deepConverted();
StringBuilder out = new StringBuilder();
boolean hadFormat = false;