55 lines
1.4 KiB
JavaScript
55 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
const {sleep} = require('../utils');
|
|
const conf = require('../conf');
|
|
const {CJbot} = require('../model/minecraft');
|
|
const inventoryViewer = require('mineflayer-web-inventory');
|
|
|
|
const commands = require('./commands');
|
|
const {onJoin} = require('./player_list');
|
|
const {Ai} = require('./ai');
|
|
// const plugins = {
|
|
// Swing: require('./swing'),
|
|
// }
|
|
|
|
CJbot.pluginAdd(require('./swing'));
|
|
CJbot.pluginAdd(require('./craft'));
|
|
CJbot.pluginAdd(require('./tp'));
|
|
CJbot.pluginAdd(require('./ai'));
|
|
CJbot.pluginAdd(require('./guardianFarm'));
|
|
|
|
for(let name in conf.mc.bots){
|
|
if(CJbot.bots[name]) continue;
|
|
let bot = new CJbot({name, host: conf.mc.host, ...conf.mc.bots[name]});
|
|
CJbot.bots[name] = bot;
|
|
|
|
for(let command of conf.mc.bots[name].commands || ['default']){
|
|
for(let [name, toAdd] of Object.entries(commands[command])){
|
|
bot.addCommand(name, toAdd)
|
|
}
|
|
}
|
|
|
|
if(conf.mc.bots[name].plugins){
|
|
for(let pluginName in conf.mc.bots[name].plugins){
|
|
bot.pluginLoad(pluginName, conf.mc.bots[name].plugins[pluginName]);
|
|
}
|
|
}
|
|
}
|
|
|
|
(async ()=>{try{
|
|
for(let name in CJbot.bots){
|
|
let bot = CJbot.bots[name];
|
|
if(bot.autoConnect){
|
|
console.log('Trying to connect', name)
|
|
console.log('Status for', name, await bot.connect());
|
|
|
|
await sleep(30000);
|
|
}
|
|
}
|
|
}catch(e){
|
|
console.log('!!!!!!!! error:', e)
|
|
}})()
|
|
|
|
|
|
// module.exports = {bot: ez, henry, owen, linda, jimin, nova, ez};
|