@baipiaodajun/mcbots 1.2.4 → 1.2.5

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/server.js +34 -6
package/README.md CHANGED
@@ -63,7 +63,7 @@ docker run -d \
63
63
  - 目前该功能处于 **实验状态**,可能会导致一些 **意料之外的问题**
64
64
  - 如果需要稳定使用,推荐继续使用 **1.1 版本**
65
65
  - **1.2.4** 优化机器人断开逻辑,避免幽灵机器人出现。
66
-
66
+ - **1.2.5** 根据群友建议加入服务备注,以便能够区分是哪一家服务器,因为一些服务器没有域名。
67
67
  ---
68
68
 
69
69
  ### 页面更新
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baipiaodajun/mcbots",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "Minecraft bot and status dashboard for multi-server management",
5
5
  "main": "server.js",
6
6
  "scripts": {
package/server.js CHANGED
@@ -42,6 +42,7 @@ if (fs.existsSync(CONFIG_FILE)) {
42
42
  SERVERS.length = 0;
43
43
  SERVERS.push(...fileConfig);
44
44
  console.log(`从 ${CONFIG_FILE} 加载服务器配置成功,数量: ${SERVERS.length} 项`);
45
+ debugPrint(`配置为:${JSON.stringify(SERVERS, null, 2)}`);
45
46
  loaded = true;
46
47
  } else {
47
48
  console.warn('配置文件内容不是数组,已忽略');
@@ -206,11 +207,12 @@ class HotUpdateAuth {
206
207
  const hotUpdateAuth =new HotUpdateAuth();
207
208
  // Minecraft机器人管理器
208
209
  class MinecraftBotManager {
209
- constructor(host, port, minBots, maxBots, version) {
210
+ constructor(host, port, minBots, maxBots, version,note) {
210
211
  this.host = host;
211
212
  this.port = port;
212
213
  this.minBots = minBots;
213
214
  this.maxBots = maxBots;
215
+ this.note=note;
214
216
  this.version = version || "1.20.1";
215
217
  this.currentBots = 0;
216
218
  this.activeBots = new Map();
@@ -233,6 +235,7 @@ class MinecraftBotManager {
233
235
  port: port,
234
236
  minBots: minBots,
235
237
  maxBots: maxBots,
238
+ note:note,
236
239
  currentBots: 0,
237
240
  activeBots: [],
238
241
  lastUpdate: Date.now(),
@@ -825,14 +828,28 @@ class StatusServer {
825
828
  .server-header {
826
829
  display: flex;
827
830
  justify-content: space-between;
828
- align-items: center;
829
831
  margin-bottom: 15px;
832
+ gap: 8px;
833
+ }
834
+ .server-note {
835
+ font-size: 0.85rem;
836
+ font-weight: 600;
837
+ display: inline-block;
838
+ padding: 6px 12px;
839
+ background: #e6f0ff;
840
+ color: #1e40af;
841
+ border-radius: 20px;
842
+ border: 1px solid #93c5fd;
843
+ flex-shrink: 0;
844
+ white-space: nowrap;
845
+ margin-right: 8px;
830
846
  }
831
-
832
847
  .server-title {
833
848
  font-size: 1.2rem;
834
849
  font-weight: 600;
835
850
  color: #2d3748;
851
+ min-width: 0;
852
+ flex: 1;
836
853
  }
837
854
 
838
855
  .status-badge {
@@ -841,6 +858,7 @@ class StatusServer {
841
858
  font-size: 0.85rem;
842
859
  font-weight: 600;
843
860
  text-transform: uppercase;
861
+ flex-shrink: 0;
844
862
  }
845
863
 
846
864
  .status-healthy {
@@ -1030,9 +1048,9 @@ class StatusServer {
1030
1048
  <div class="server-card ${server.status}">
1031
1049
  <div class="server-header">
1032
1050
  <div class="server-title">${server.host}:${server.port}</div>
1051
+ ${server.note ? `<div class="server-note">${server.note}</div>` : "" }
1033
1052
  <div class="status-badge ${statusClass}">${statusText}</div>
1034
1053
  </div>
1035
-
1036
1054
  <div class="server-info">
1037
1055
  <div class="info-item">
1038
1056
  <div class="info-label">机器人数量</div>
@@ -1584,7 +1602,8 @@ async function initialize() {
1584
1602
  server.port,
1585
1603
  server.minBots,
1586
1604
  server.maxBots,
1587
- server.version
1605
+ server.version,
1606
+ server.note ?? ""
1588
1607
  )
1589
1608
  );
1590
1609
 
@@ -1639,6 +1658,14 @@ async function hotUpdateServers() {
1639
1658
  // 完全一致:保留,并从 newServerMap 删除(避免重复创建)
1640
1659
  newServerMap.delete(key);
1641
1660
  // 状态保持最新(可选:刷新 lastUpdate)
1661
+
1662
+ //备注处理,不重建机器人,只是更新备注
1663
+ if (manager.note !== newConfig.note) {
1664
+ manager.note = newConfig.note;
1665
+ const status = globalServerStatus.servers.get(key);
1666
+ if (status) status.note = newConfig.note;
1667
+ }
1668
+
1642
1669
  const status = globalServerStatus.servers.get(key);
1643
1670
  if (status) status.lastUpdate = Date.now();
1644
1671
  } else {
@@ -1675,7 +1702,8 @@ async function hotUpdateServers() {
1675
1702
  config.port,
1676
1703
  config.minBots,
1677
1704
  config.maxBots,
1678
- config.version
1705
+ config.version,
1706
+ config.note
1679
1707
  );
1680
1708
  newManager.startMonitoring();
1681
1709
  botManagers.push(newManager);