From 81db7de846bdc29145b381dfa5bca7d9d1b2a89b Mon Sep 17 00:00:00 2001 From: Boy Date: Thu, 19 Sep 2024 01:51:20 +0200 Subject: [PATCH] fix: read LiteralComponent content and parse to AdventureComponent before transforming --- build.gradle.kts | 5 ++--- .../com/mineinabyss/emojy/nms/v1_21_R1/EmojyNMSHandler.kt | 8 +++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 732a66c..9692289 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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") } } @@ -67,7 +66,7 @@ tasks { } runServer { - minecraftVersion("1.20.6") + minecraftVersion("1.21") } shadowJar { 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 d77f26a..893183f 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 @@ -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 @@ -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 @@ -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 {