From 28bd50a105ea5b11cd3727eb942d6da5517d4908 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Tue, 22 Feb 2022 10:10:51 +0100 Subject: [PATCH] Fix legacy component text wrapping Fixes #2821 --- .../protocol1_13to1_12_2/ChatRewriter.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/ChatRewriter.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/ChatRewriter.java index 9569573c6..1d3c00f13 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/ChatRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/ChatRewriter.java @@ -30,14 +30,11 @@ public final class ChatRewriter { public static final GsonComponentSerializer HOVER_GSON_SERIALIZER = GsonComponentSerializer.builder().emitLegacyHoverEvent().legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.get()).build(); public static String legacyTextToJsonString(String message, boolean itemData) { - Component component = Component.text(builder -> { - if (itemData) { - builder.decoration(TextDecoration.ITALIC, false); - } - - // Not used for chat messages, so no need for url extraction - builder.append(LegacyComponentSerializer.legacySection().deserialize(message)); - }); + // Not used for chat messages, so no need for url extraction + Component component = LegacyComponentSerializer.legacySection().deserialize(message); + if (itemData) { + component = Component.text().decoration(TextDecoration.ITALIC, false).append(component).build(); + } return GsonComponentSerializer.gson().serialize(component); }