diff --git a/v1_20_R4/src/main/kotlin/com/mineinabyss/emojy/nms/v1_20_R4/EmojyNMSHandler.kt b/v1_20_R4/src/main/kotlin/com/mineinabyss/emojy/nms/v1_20_R4/EmojyNMSHandler.kt index b8ebc72..647ff51 100644 --- a/v1_20_R4/src/main/kotlin/com/mineinabyss/emojy/nms/v1_20_R4/EmojyNMSHandler.kt +++ b/v1_20_R4/src/main/kotlin/com/mineinabyss/emojy/nms/v1_20_R4/EmojyNMSHandler.kt @@ -20,6 +20,7 @@ import net.minecraft.core.NonNullList import net.minecraft.network.Connection import net.minecraft.network.chat.ChatType import net.minecraft.network.chat.Component +import net.minecraft.network.chat.contents.PlainTextContents.LiteralContents import net.minecraft.network.protocol.Packet import net.minecraft.network.protocol.common.ClientboundDisconnectPacket import net.minecraft.network.protocol.common.ClientboundResourcePackPushPacket @@ -153,7 +154,11 @@ class EmojyNMSHandler(emojy: EmojyPlugin) : IEmojyNMSHandler { } fun Component.transformEmotes(locale: Locale? = null, insert: Boolean = false): Component { - return PaperAdventure.asVanilla(PaperAdventure.asAdventure(this).transformEmotes(locale, insert)) + return when { + // Sometimes a NMS component is partially Literal, so ensure entire thing is just one LiteralContent with no extra data + contents is LiteralContents && style.isEmpty && siblings.isEmpty() -> (contents as LiteralContents).text.miniMsg() + else -> PaperAdventure.asAdventure(this) + }.transformEmotes(locale, insert).let(PaperAdventure::asVanilla) } fun Component.escapeEmoteIDs(player: Player?): Component { diff --git a/v1_21_R1/src/main/kotlin/com/mineinabyss/emojy/nms/v1_21_R1/EmojyNMSHandler.kt b/v1_21_R1/src/main/kotlin/com/mineinabyss/emojy/nms/v1_21_R1/EmojyNMSHandler.kt index 893183f..b121d5a 100644 --- a/v1_21_R1/src/main/kotlin/com/mineinabyss/emojy/nms/v1_21_R1/EmojyNMSHandler.kt +++ b/v1_21_R1/src/main/kotlin/com/mineinabyss/emojy/nms/v1_21_R1/EmojyNMSHandler.kt @@ -164,10 +164,11 @@ class EmojyNMSHandler(emojy: EmojyPlugin) : IEmojyNMSHandler { } fun Component.transformEmotes(locale: Locale? = null, insert: Boolean = false): Component { - return PaperAdventure.asVanilla(when (val contents = contents) { - is LiteralContents -> contents.text.miniMsg() + return when { + // Sometimes a NMS component is partially Literal, so ensure entire thing is just one LiteralContent with no extra data + contents is LiteralContents && style.isEmpty && siblings.isEmpty() -> (contents as LiteralContents).text.miniMsg() else -> PaperAdventure.asAdventure(this) - }.transformEmotes(locale, insert)) + }.transformEmotes(locale, insert).let(PaperAdventure::asVanilla) } fun Component.escapeEmoteIDs(player: Player?): Component {