Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
Bump MiniMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoDog896 committed Mar 27, 2022
1 parent 57c1c83 commit 0e4691a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
17 changes: 4 additions & 13 deletions src/main/kotlin/world/cepi/chatextension/events/FormattedChat.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ->
Expand Down Expand Up @@ -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())
}
}

Expand Down

0 comments on commit 0e4691a

Please sign in to comment.