Fix legacy component text wrapping

Fixes #2821
This commit is contained in:
Nassim Jahnke 2022-02-22 10:10:51 +01:00
parent 46bd5814e3
commit 28bd50a105
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
1 changed files with 5 additions and 8 deletions

View File

@ -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);
}