koishi-plugin-mc-serverlist 1.1.0 → 1.1.1

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.
@@ -22,6 +22,13 @@ export type McStatusResponse = {
22
22
  obfuscated?: boolean;
23
23
  };
24
24
  favicon?: string;
25
+ modinfo?: {
26
+ type: string;
27
+ modList: {
28
+ modid: string;
29
+ version: string;
30
+ }[];
31
+ };
25
32
  };
26
33
  export declare function formatMotdHtml(description?: McStatusResponse['description']): string;
27
34
  export declare function queryServerStatus(address: string): Promise<McStatusResponse>;
package/lib/index.d.ts CHANGED
@@ -17,5 +17,5 @@ export interface Config {
17
17
  debug: boolean;
18
18
  }
19
19
  export declare const Config: Schema<Config>;
20
- export declare const usage = "\n\u67E5\u8BE2Minecraft JAVA \u7248\u670D\u52A1\u5668\u72B6\u6001\u7684\u63D2\u4EF6, \u5E76\u751F\u6210\u56FE\u7247\u3002\u652F\u6301\u540C\u65F6\u67E5\u8BE2\u591A\u4E2A\u670D\u52A1\u5668\u3002 \n~~\u4F7F\u7528 mcsrvstat.us API~~ \nv1.1.0 : \u4F7F\u7528 TCP ping \u534F\u8BAE\u76F4\u63A5\u67E5\u8BE2\u670D\u52A1\u5668\u72B6\u6001\u3002\n";
20
+ export declare const usage = "\n\u67E5\u8BE2Minecraft JAVA \u7248\u670D\u52A1\u5668\u72B6\u6001\u7684\u63D2\u4EF6, \u5E76\u751F\u6210\u56FE\u7247\u3002\u652F\u6301\u540C\u65F6\u67E5\u8BE2\u591A\u4E2A\u670D\u52A1\u5668\u3002 \n\n### \u7528\u6CD5: \nmcs [\u670D\u52A1\u5668\u5730\u5740] \n\u4F8B\u5982: \nmcs hypixel.net \n\u5982\u679C\u4E0D\u6307\u5B9A\u670D\u52A1\u5668\u5730\u5740, \u5219\u67E5\u8BE2\u914D\u7F6E\u6587\u4EF6\u4E2D\u7684\u6240\u6709\u670D\u52A1\u5668\u3002\n\n~~\u4F7F\u7528 mcsrvstat.us API~~ \nv1.1.0 : \u4F7F\u7528 TCP ping \u534F\u8BAE\u76F4\u63A5\u67E5\u8BE2\u670D\u52A1\u5668\u72B6\u6001\u3002\n";
21
21
  export declare function apply(ctx: Context, config: Config): void;
package/lib/index.js CHANGED
@@ -166,8 +166,14 @@ function renderComponent(component, inherited = {}) {
166
166
  obfuscated: component.obfuscated ?? inherited.obfuscated
167
167
  };
168
168
  let html = "";
169
- if (typeof component.text === "string") {
170
- html += wrapStyledText(component.text, style);
169
+ const baseText = typeof component.text === "string" ? component.text : typeof component.translate === "string" ? component.translate : "";
170
+ if (baseText) {
171
+ html += baseText.includes("§") ? renderLegacyToHtml(baseText) : wrapStyledText(baseText, style);
172
+ }
173
+ if (Array.isArray(component.with)) {
174
+ for (const part of component.with) {
175
+ html += renderComponent(part, style);
176
+ }
171
177
  }
172
178
  if (Array.isArray(component.extra)) {
173
179
  for (const child of component.extra) {
@@ -420,50 +426,39 @@ __name(bodyHtml, "bodyHtml");
420
426
  async function getStatus(serverName, serverIP, config) {
421
427
  let mcdata;
422
428
  try {
423
- mcdata = await queryServerStatus(serverIP);
429
+ const status = await queryServerStatus(serverIP);
424
430
  if (config.debug) {
425
431
  try {
426
- const { favicon, ...debugData } = mcdata;
432
+ const { favicon, modinfo, ...debugData } = status;
427
433
  logger.info("查询服务器:", `${serverName}`, `(${serverIP})`);
428
434
  logger.info("精简返回数据:", JSON.stringify(debugData, null, 2));
429
435
  } catch (e) {
430
436
  logger.info("调试信息时出错:", e);
431
437
  }
432
438
  }
433
- const status = mcdata;
434
439
  let result = "";
435
- if (status) {
436
- result += `<p>${serverName}`;
437
- if (config.showIP) {
438
- result += ` ${serverIP} </p>`;
439
- } else {
440
- result += `</p>`;
441
- }
442
- if (config.showMotd) {
443
- result += `<p>${formatMotdHtml(status.description)}</p>`;
444
- }
445
- const versionName = status.version?.name || "未知";
446
- result += `<p>版本: ${escapeHtml2(versionName)}</p>`;
447
- const online = status.players?.online ?? 0;
448
- const max = status.players?.max ?? 0;
449
- if (online > 0) {
450
- if (status.players?.sample && status.players.sample.length > 0) {
451
- const playerNames = status.players.sample.map((player) => player.name).join(", ");
452
- result += `<p>在线玩家(${online}/${max}): ${escapeHtml2(playerNames)}</p>`;
453
- } else {
454
- result += `<p>在线玩家(${online}/${max}): 无法获取</p>`;
455
- }
456
- } else {
457
- result += `<p>在线玩家(${online}/${max}): 无人在线</p>`;
458
- }
440
+ result += `<p>${serverName}`;
441
+ if (config.showIP) {
442
+ result += ` ${serverIP} </p>`;
459
443
  } else {
460
- result += `<p>${serverName}`;
461
- if (config.showIP) {
462
- result += ` ${serverIP} </p>`;
444
+ result += `</p>`;
445
+ }
446
+ if (config.showMotd) {
447
+ result += `<p>${formatMotdHtml(status.description)}</p>`;
448
+ }
449
+ const versionName = status.version?.name || "未知";
450
+ result += `<p>版本: ${escapeHtml2(versionName)}</p>`;
451
+ const online = status.players?.online ?? 0;
452
+ const max = status.players?.max ?? 0;
453
+ if (online > 0) {
454
+ if (status.players?.sample && status.players.sample.length > 0) {
455
+ const playerNames = status.players.sample.map((player) => player.name).join(", ");
456
+ result += `<p>在线玩家(${online}/${max}): ${escapeHtml2(playerNames)}</p>`;
463
457
  } else {
464
- result += `</p>`;
458
+ result += `<p>在线玩家(${online}/${max}): 无法获取</p>`;
465
459
  }
466
- result += "<p>查询失败</p>";
460
+ } else {
461
+ result += `<p>在线玩家(${online}/${max}): 无人在线</p>`;
467
462
  }
468
463
  return { result, icon: status.favicon || "" };
469
464
  } catch (error) {
@@ -542,6 +537,13 @@ var Config = import_koishi2.Schema.object({
542
537
  });
543
538
  var usage = `
544
539
  查询Minecraft JAVA 版服务器状态的插件, 并生成图片。支持同时查询多个服务器。
540
+
541
+ ### 用法:
542
+ mcs [服务器地址]
543
+ 例如:
544
+ mcs hypixel.net
545
+ 如果不指定服务器地址, 则查询配置文件中的所有服务器。
546
+
545
547
  ~~使用 mcsrvstat.us API~~
546
548
  v1.1.0 : 使用 TCP ping 协议直接查询服务器状态。
547
549
  `;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-mc-serverlist",
3
3
  "description": "查询Minecraft JAVA 版服务器状态的插件, 并生成图片。支持同时查询多个服务器。",
4
- "version": "1.1.0",
4
+ "version": "1.1.1",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
package/readme.md CHANGED
@@ -7,5 +7,11 @@
7
7
 
8
8
  由 [koishi-plugin-mc-server-status](https://github.com/Kokoro-js/koishi-plugin-mc-server-status) 插件修改实现。
9
9
 
10
+ ### 用法:
11
+ ``mcs [服务器地址]``
12
+ 例如:
13
+ ``mcs hypixel.net``
14
+ 如果不指定服务器地址, 则查询配置文件中的所有服务器。
15
+
10
16
  ~~使用 mcsrvstat.us API~~
11
17
  v1.1.0 : 使用 TCP ping 协议直接实现查询功能(Codex 大作)