ChatComponentFormatted
基本信息
| 属性 | 值 |
|---|---|
| 类名 | myessentials.chat.api.ChatComponentFormatted |
| 类型 | class extends ChatComponentList,2 个方法 |
| 启用版本 | Minecraft 1.7.10 |
功能
在文本组件基础上加入分隔符与旧版格式代码转换。
| 方法 | 说明 |
|---|---|
applyDelimiter(...) |
用分隔符连接各段文本 |
getLegacyFormattedText() |
转为 1.7.10 的 § 颜色代码串 |
实现要点
- 继承 ChatComponentList,因此同时具备文本列表能力。
getLegacyFormattedText()是 1.7.10 特有的需求:服务端向客户端 发送聊天时既可用 JSON 组件,也可用§颜色代码串;本方法提供后者。- 2 个方法分别对应「拼装」与「降级输出」两个方向。
- 格式化过程中可能用到 LocalManager 的本地化键。
相关条目
- ChatComponentList - 父类
- ChatManager - 消息发送
- LocalManager - 本地化来源
- ChatUtils - 旧版文本转换工具