@baipiaodajun/mcbots 1.2.2 → 1.2.3
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/package.json +1 -1
- package/server.js +16 -2
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -354,9 +354,23 @@ class MinecraftBotManager {
|
|
|
354
354
|
console.log(`[${this.host}:${this.port}] 已达到最大机器人限制: ${this.maxBots}`);
|
|
355
355
|
return null;
|
|
356
356
|
}
|
|
357
|
-
|
|
358
|
-
|
|
357
|
+
|
|
358
|
+
if (!botName) {
|
|
359
|
+
if (this.pendingReconnect.size > 0) {
|
|
360
|
+
botName = this.pendingReconnect.keys().next().value;
|
|
361
|
+
this.pendingReconnect.delete(botName); // 用完就移除,避免重复分配
|
|
362
|
+
debugPrint(`[${this.host}:${this.port}] 优先重用待重连名字: ${botName} (剩余待重连: ${this.pendingReconnect.size})`);
|
|
363
|
+
} else {
|
|
364
|
+
botName = this.generateBotName();
|
|
365
|
+
debugPrint(`[${this.host}:${this.port}] 无待重连名字,生成新名字: ${botName}`);
|
|
366
|
+
}
|
|
367
|
+
} else {
|
|
368
|
+
if (this.pendingReconnect.has(botName)) {
|
|
369
|
+
this.pendingReconnect.delete(botName);
|
|
370
|
+
debugPrint(`[${this.host}:${this.port}] 使用指定的重连名字: ${botName} (已从待重连名单移除)`);
|
|
371
|
+
}
|
|
359
372
|
}
|
|
373
|
+
|
|
360
374
|
try {
|
|
361
375
|
console.log(`[${this.host}:${this.port}] 创建机器人: ${botName}`);
|
|
362
376
|
const bot = mineflayer.createBot({
|