diff --git a/build.gradle.kts b/build.gradle.kts index 41f3eeb..2a2cf3e 100755 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -56,7 +56,7 @@ dependencies { // Add LevelExtension compileOnly("com.github.Project-Cepi:LevelExtension:cae5707195") - implementation("net.kyori:adventure-text-minimessage:4.1.0-SNAPSHOT") + compileOnly("net.kyori:adventure-text-minimessage:4.2.0-SNAPSHOT") // Jansi compileOnly("org.jline:jline-terminal-jansi:3.21.0") diff --git a/src/main/kotlin/world/cepi/chatextension/events/FormattedChat.kt b/src/main/kotlin/world/cepi/chatextension/events/FormattedChat.kt index aaff613..b047ccc 100755 --- a/src/main/kotlin/world/cepi/chatextension/events/FormattedChat.kt +++ b/src/main/kotlin/world/cepi/chatextension/events/FormattedChat.kt @@ -5,17 +5,13 @@ import net.kyori.adventure.text.Component import net.kyori.adventure.text.TextReplacementConfig import net.kyori.adventure.text.format.NamedTextColor import net.kyori.adventure.text.minimessage.MiniMessage -import net.kyori.adventure.text.minimessage.markdown.DiscordFlavor -import net.kyori.adventure.text.minimessage.transformation.TransformationType import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer -import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer -import net.minestom.server.MinecraftServer -import net.minestom.server.entity.Player import net.minestom.server.event.player.PlayerChatEvent import net.minestom.server.sound.SoundEvent import org.slf4j.LoggerFactory import world.cepi.chatextension.emojis.Emoji import world.cepi.kstom.Manager +import world.cepi.kstom.adventure.plainText import world.cepi.kstom.util.component1 import world.cepi.kstom.util.component2 import world.cepi.kstom.util.component3 @@ -24,16 +20,11 @@ object FormattedChat { val logger = LoggerFactory.getLogger("Chat") - val miniMessageFormat = MiniMessage.builder() - .removeDefaultTransformations() - .transformation(TransformationType.DECORATION) - .markdown() - .markdownFlavor(DiscordFlavor.get()) - .build() + val miniMessageFormat = MiniMessage.miniMessage() // TODO w h a t. (please format this code or something i dont know god) fun styleFormattedChat(event: PlayerChatEvent) = event.setChatFormat { chatEvent -> - val messageComponent = miniMessageFormat.parse(chatEvent.message) + val messageComponent = miniMessageFormat.deserialize(chatEvent.message) .let { // Fold the players, replacing the initial value's text one by one return@let Manager.connection.onlinePlayers.fold(it) { acc, player -> @@ -91,7 +82,7 @@ object FormattedChat { .append(Component.space()) .append(messageComponent.color(NamedTextColor.WHITE)) .also { - logger.info(LegacyComponentSerializer.legacySection().serialize(it)) + logger.info(it.plainText()) } }