ProtocolStringReplacer
ProtocolStringReplacer copied to clipboard
Adventure MiniMessage
Is your feature request related to a problem? Please describe. idk
Describe the solution you'd like 可以使用MiniMessage
Describe alternatives you've considered Triton (?
Additional context
package catmoe.fallencrystal.moefilter.util.message.component
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.minimessage.MiniMessage
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer
import net.md_5.bungee.api.chat.BaseComponent
import net.md_5.bungee.api.chat.TextComponent
import net.md_5.bungee.chat.ComponentSerializer
object ComponentUtil {
fun toBaseComponent(component: Component): Array<BaseComponent> {
return ComponentSerializer.parse(GsonComponentSerializer.gson().serialize(component))
}
fun toBaseComponents(component: Component): BaseComponent {
return TextComponent(*ComponentSerializer.parse(GsonComponentSerializer.gson().serialize(component)))
}
fun parse(str: String): Component { return MiniMessage.miniMessage().deserialize(str) }
}
我在BungeeCord上用这样的方式解析MiniMessage并转换为BaseComponent以发送.
将数据包中的Component转换为 MiniMessage -> 替换 -> 转换回 Component 可能过于耗时, 通过配置文件读取 MiniMessage -> 转换为 Component 来替换数据包中的Component 也需要实现一些繁琐的判断. 待定