koishi-plugin-minecraft-search 2.0.13 → 2.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +25 -12
- package/package.json +1 -1
- package/readme.md +7 -0
package/lib/index.js
CHANGED
|
@@ -199,20 +199,33 @@ function apply(ctx, config) {
|
|
|
199
199
|
if (!result.online) {
|
|
200
200
|
return `🔴 ${displayName} 当前离线`;
|
|
201
201
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
if (typeof
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
202
|
+
function parseChatComponent(component) {
|
|
203
|
+
if (!component) return "";
|
|
204
|
+
if (typeof component === "string") return component;
|
|
205
|
+
if (typeof component !== "object") return String(component);
|
|
206
|
+
let text = "";
|
|
207
|
+
if (component.text) {
|
|
208
|
+
text += component.text;
|
|
209
|
+
}
|
|
210
|
+
if (component.translate) {
|
|
211
|
+
text += component.translate;
|
|
212
|
+
}
|
|
213
|
+
if (Array.isArray(component.extra)) {
|
|
214
|
+
for (const extra of component.extra) {
|
|
215
|
+
text += parseChatComponent(extra);
|
|
214
216
|
}
|
|
215
217
|
}
|
|
218
|
+
if (Array.isArray(component.with)) {
|
|
219
|
+
for (const w of component.with) {
|
|
220
|
+
text += parseChatComponent(w);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return text;
|
|
224
|
+
}
|
|
225
|
+
__name(parseChatComponent, "parseChatComponent");
|
|
226
|
+
let motdText = "暂无描述";
|
|
227
|
+
if (result.description) {
|
|
228
|
+
let descriptionStr = parseChatComponent(result.description);
|
|
216
229
|
descriptionStr = descriptionStr.replace(/§[0-9a-fk-or]/gi, "");
|
|
217
230
|
motdText = descriptionStr.replace(/\n/g, " ").replace(/\s+/g, " ").trim();
|
|
218
231
|
}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
- 支持查询指定服务器状态(详细信息)
|
|
13
13
|
- 可配置查询超时时间
|
|
14
14
|
- 自动移除 Minecraft 颜色代码,显示纯文本 MOTD
|
|
15
|
+
- 支持解析聊天组件格式 MOTD(包括 translate、extra、with 等字段)
|
|
15
16
|
|
|
16
17
|
### ⚡ 服务器电源控制
|
|
17
18
|
- 支持通过麦块联机 API 启动服务器
|
|
@@ -188,6 +189,12 @@ mc/资源 1 # 查看ID为1的麦块服务器资源使用情况
|
|
|
188
189
|
<details>
|
|
189
190
|
<summary>点我查看更新日志详情</summary>
|
|
190
191
|
|
|
192
|
+
### v2.0.14
|
|
193
|
+
- 优化 MOTD 解析,支持 Minecraft 聊天组件格式
|
|
194
|
+
- 新增对 `translate` 字段的支持,兼容 1.12.2 等旧版本服务器
|
|
195
|
+
- 支持解析 `extra` 和 `with` 数组字段
|
|
196
|
+
- 修复旧版本服务器 MOTD 显示原始 JSON 的问题
|
|
197
|
+
|
|
191
198
|
### v2.0.13
|
|
192
199
|
- 优化 `mc/修改服务器` 指令,新增 `-a` 选项支持合并输入服务器地址和端口
|
|
193
200
|
- 支持类似 `127.0.0.1:25565` 的格式,代码自动分离IP和端口
|