Skip to content

Commit

Permalink
fix: read LiteralComponent content and parse to AdventureComponent be…
Browse files Browse the repository at this point in the history
…fore transforming
  • Loading branch information
Boy0000 committed Sep 18, 2024
1 parent e01f36d commit 81db7de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 2 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ allprojects {
repositories {
maven("https://repo.mineinabyss.com/releases")
maven("https://repo.mineinabyss.com/snapshots")
maven("https://hub.jeff-media.com/nexus/repository/jeff-media-public/")
mavenLocal()
}

dependencies {
implementation("com.jeff_media:MorePersistentDataTypes:2.4.0")
implementation("com.jeff-media:MorePersistentDataTypes:2.4.0")
}
}

Expand Down Expand Up @@ -67,7 +66,7 @@ tasks {
}

runServer {
minecraftVersion("1.20.6")
minecraftVersion("1.21")
}

shadowJar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ 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
Expand All @@ -22,6 +24,7 @@ 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.LiteralContents
import net.minecraft.network.protocol.Packet
import net.minecraft.network.protocol.common.ClientboundDisconnectPacket
import net.minecraft.network.protocol.common.ClientboundResourcePackPushPacket
Expand Down Expand Up @@ -161,7 +164,10 @@ 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 PaperAdventure.asVanilla(when (val contents = contents) {
is LiteralContents -> contents.text.miniMsg()
else -> PaperAdventure.asAdventure(this)
}.transformEmotes(locale, insert))
}

fun Component.escapeEmoteIDs(player: Player?): Component {
Expand Down

0 comments on commit 81db7de

Please sign in to comment.