@baipiaodajun/mcbots 1.2.5 → 1.2.7

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 +9 -3
  2. package/package.json +5 -2
  3. package/server.js +6 -5
package/README.md CHANGED
@@ -10,7 +10,11 @@
10
10
 
11
11
 
12
12
  ## 用法
13
-
13
+ ### npx
14
+ ```
15
+ export SERVERS_JSON='[{"host":"mc-yy.io","port":25565}]'
16
+ npx @baipiaodajun/mcbots
17
+ ```
14
18
  ### nodejs
15
19
  新建一个 index.js 文件,内容如下:
16
20
  其中内容替换成你自己的MC服务器地址和端口,其他可以根据情况改变,可以添加多台服务器。
@@ -52,7 +56,7 @@ npm install && npm run start
52
56
  ```
53
57
  docker run -d \
54
58
  --name mcbot \
55
- -e SERVERS_JSON='[{"host":"mc-yy.io","port":25565,"minBots":1,"maxBots":3,"version":"1.20.1"},{"host":"mc-xx.io","port":25565,"minBots":1,"maxBots":3,"version":"1.20.1"}]' \
59
+ -e SERVERS_JSON='[{"host":"mc-yy.io","port":25565,"minBots":1,"maxBots":3},{"host":"mc-xx.io","port":25565,"minBots":1,"maxBots":3}]' \
56
60
  -p 3000:3000 \
57
61
  mingli2038/mcbot:latest
58
62
  ```
@@ -61,9 +65,11 @@ docker run -d \
61
65
 
62
66
  - 新版本引入了 **热更新功能:`SERVER_JSON`**
63
67
  - 目前该功能处于 **实验状态**,可能会导致一些 **意料之外的问题**
64
- - 如果需要稳定使用,推荐继续使用 **1.1 版本**
68
+ - ~~如果需要稳定使用,推荐继续使用 **1.1 版本**~~
65
69
  - **1.2.4** 优化机器人断开逻辑,避免幽灵机器人出现。
66
70
  - **1.2.5** 根据群友建议加入服务备注,以便能够区分是哪一家服务器,因为一些服务器没有域名。
71
+ - **1.2.6** mineflayer更新到4.35,得益于此,现在可以直连1.21.8-1.21.11的MC离线模式服务器而不需要通过兼容版本插件,mc版本|最大机器人数|最小机器人数变成可选项,有默认值,mc版本使用上游自动识别功能。
72
+ - **1.2.7** 现在可以直接使用npx来执行这个包。
67
73
  ---
68
74
 
69
75
  ### 页面更新
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@baipiaodajun/mcbots",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "description": "Minecraft bot and status dashboard for multi-server management",
5
5
  "main": "server.js",
6
6
  "scripts": {
7
7
  "start": "node server.js"
8
8
  },
9
+ "bin": {
10
+ "mcbots": "server.js"
11
+ },
9
12
  "keywords": [
10
13
  "minecraft",
11
14
  "bot",
@@ -16,7 +19,7 @@
16
19
  "dependencies": {
17
20
  "cookie-parser": "^1.4.7",
18
21
  "express": "^4.18.2",
19
- "mineflayer": "^4.33.0",
22
+ "mineflayer": "4.35",
20
23
  "node-fetch": "^2.7.0"
21
24
  },
22
25
  "files": [
package/server.js CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  const mineflayer = require('mineflayer');
2
3
  const express = require('express');
3
4
  const net = require('net');
@@ -210,10 +211,10 @@ class MinecraftBotManager {
210
211
  constructor(host, port, minBots, maxBots, version,note) {
211
212
  this.host = host;
212
213
  this.port = port;
213
- this.minBots = minBots;
214
- this.maxBots = maxBots;
214
+ this.minBots = minBots || 1;
215
+ this.maxBots = maxBots || 3;
215
216
  this.note=note;
216
- this.version = version || "1.20.1";
217
+ this.version = version || false;
217
218
  this.currentBots = 0;
218
219
  this.activeBots = new Map();
219
220
  this.pendingReconnect = new Set(); // 等待重连的机器人名字(已断开但优先重用名字)
@@ -233,8 +234,8 @@ class MinecraftBotManager {
233
234
  globalServerStatus.servers.set(`${host}:${port}`, {
234
235
  host: host,
235
236
  port: port,
236
- minBots: minBots,
237
- maxBots: maxBots,
237
+ minBots: this.minBots,
238
+ maxBots: this.maxBots,
238
239
  note:note,
239
240
  currentBots: 0,
240
241
  activeBots: [],