Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package me.arasple.mc.trchat.api.event
import me.arasple.mc.trchat.module.display.ChatSession
import me.arasple.mc.trchat.module.display.channel.Channel
import me.arasple.mc.trchat.module.display.channel.PrivateChannel
import me.arasple.mc.trchat.util.pass
import taboolib.module.chat.ComponentText
import taboolib.module.chat.Components
import taboolib.platform.type.BukkitProxyEvent
Expand Down Expand Up @@ -38,5 +39,28 @@ class TrChatEvent(
this.component = event.component
}
}
fun getFullMessage() : String{
// 获取符合条件的格式
val format = channel.formats.firstOrNull { it.condition.pass(player) }
// 构建完整消息
val fullComponent = Components.empty()

// 添加前缀
format?.prefix?.forEach { prefix ->
prefix.value.firstOrNull { it.condition.pass(player) }?.content
?.toTextComponent(player)?.let { fullComponent.append(it) }
}

// 添加消息内容
fullComponent.append(component)

// 添加后缀
format?.suffix?.forEach { suffix ->
suffix.value.firstOrNull { it.condition.pass(player) }?.content
?.toTextComponent(player)?.let { fullComponent.append(it) }
}

val fullMessage = fullComponent.toLegacyText()
return fullMessage
}
}