Skip to content

Commit

Permalink
fix: rare case where component is empty nbt with children
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Dec 16, 2024
1 parent d402982 commit d3eeecf
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ package com.mineinabyss.emojy.nms.v1_20_R4
import com.jeff_media.morepersistentdatatypes.DataType
import com.mineinabyss.emojy.*
import com.mineinabyss.emojy.nms.IEmojyNMSHandler
import com.mineinabyss.idofront.items.editItemMeta
import com.mineinabyss.idofront.plugin.listeners
import com.mineinabyss.idofront.textcomponents.miniMsg
import com.mineinabyss.idofront.textcomponents.serialize
import io.netty.channel.Channel
import io.netty.channel.ChannelDuplexHandler
import io.netty.channel.ChannelHandlerContext
Expand All @@ -20,6 +18,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
import net.minecraft.network.chat.contents.PlainTextContents.LiteralContents
import net.minecraft.network.protocol.Packet
import net.minecraft.network.protocol.common.ClientboundDisconnectPacket
Expand Down Expand Up @@ -157,6 +156,7 @@ class EmojyNMSHandler(emojy: EmojyPlugin) : IEmojyNMSHandler {
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()
contents == PlainTextContents.EMPTY -> return Component.empty().also { siblings.map { it.transformEmotes(locale) }.forEach(it::append) }
else -> PaperAdventure.asAdventure(this)
}.transformEmotes(locale, insert).let(PaperAdventure::asVanilla)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@ package com.mineinabyss.emojy.nms.v1_21_R1
import com.jeff_media.morepersistentdatatypes.DataType
import com.mineinabyss.emojy.*
import com.mineinabyss.emojy.nms.IEmojyNMSHandler
import com.mineinabyss.emojy.nms.v1_21_R1.EmojyNMSHandler.Companion.locale
import com.mineinabyss.emojy.nms.v1_21_R1.EmojyNMSHandler.Companion.transformEmotes
import com.mineinabyss.idofront.items.editItemMeta
import com.mineinabyss.idofront.messaging.logError
import com.mineinabyss.idofront.plugin.listeners
import com.mineinabyss.idofront.textcomponents.miniMsg
import com.mineinabyss.idofront.textcomponents.serialize
import io.netty.channel.Channel
import io.netty.channel.ChannelDuplexHandler
import io.netty.channel.ChannelHandlerContext
Expand All @@ -23,7 +19,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.MutableComponent
import net.minecraft.network.chat.contents.PlainTextContents
import net.minecraft.network.chat.contents.PlainTextContents.LiteralContents
import net.minecraft.network.protocol.Packet
import net.minecraft.network.protocol.common.ClientboundDisconnectPacket
Expand Down Expand Up @@ -167,6 +163,7 @@ class EmojyNMSHandler(emojy: EmojyPlugin) : IEmojyNMSHandler {
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()
contents == PlainTextContents.EMPTY -> return Component.empty().also { siblings.map { it.transformEmotes(locale) }.forEach(it::append) }
else -> PaperAdventure.asAdventure(this)
}.transformEmotes(locale, insert).let(PaperAdventure::asVanilla)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,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
import net.minecraft.network.chat.contents.PlainTextContents.LiteralContents
import net.minecraft.network.protocol.Packet
import net.minecraft.network.protocol.common.ClientboundDisconnectPacket
Expand Down Expand Up @@ -162,6 +163,7 @@ class EmojyNMSHandler(emojy: EmojyPlugin) : IEmojyNMSHandler {
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()
contents == PlainTextContents.EMPTY -> return Component.empty().also { siblings.map { it.transformEmotes(locale) }.forEach(it::append) }
else -> PaperAdventure.asAdventure(this)
}.transformEmotes(locale, insert).let(PaperAdventure::asVanilla)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,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
import net.minecraft.network.chat.contents.PlainTextContents.LiteralContents
import net.minecraft.network.protocol.Packet
import net.minecraft.network.protocol.common.ClientboundDisconnectPacket
Expand Down Expand Up @@ -162,6 +163,7 @@ class EmojyNMSHandler(emojy: EmojyPlugin) : IEmojyNMSHandler {
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()
contents == PlainTextContents.EMPTY -> return Component.empty().also { siblings.map { it.transformEmotes(locale) }.forEach(it::append) }
else -> PaperAdventure.asAdventure(this)
}.transformEmotes(locale, insert).let(PaperAdventure::asVanilla)
}
Expand Down

0 comments on commit d3eeecf

Please sign in to comment.