|
|
|
@ -10,31 +10,21 @@ const mineflayer = require("mineflayer"); |
|
|
|
|
// const { createGetAccessor } = require('typescript');
|
|
|
|
|
|
|
|
|
|
const bot = |
|
|
|
|
!isNaN(parseInt(process.argv[3])) && parseInt(process.argv[3]) > 1e4 ? |
|
|
|
|
!isNaN(parseInt(process.argv[3])) && parseInt(process.argv[3]) > 1e2 ? |
|
|
|
|
mineflayer.createBot({ |
|
|
|
|
host: process.argv[2] || 'localhost', // Change this to the ip you want.
|
|
|
|
|
port: parseInt(process.argv[3]) // || 58471,
|
|
|
|
|
host: process.argv[2] || process.env.MINECRAFT_HOST || 'localhost', // Change this to the ip you want.
|
|
|
|
|
port: parseInt(process.argv[3]) || process.env.MINECRAFT_PORT // || 58471,
|
|
|
|
|
}) |
|
|
|
|
: |
|
|
|
|
mineflayer.createBot({ |
|
|
|
|
host: process.argv[2] || 'localhost', // Change this to the ip you want.
|
|
|
|
|
username: process.argv[3] || "tank2004@gmx.de", |
|
|
|
|
password: process.argv[4] || "Hellfire666!", |
|
|
|
|
// port: process.argv[5] || 58471,
|
|
|
|
|
host: process.argv[2] || process.env.MINECRAFT_HOST || 'localhost', // Change this to the ip you want.
|
|
|
|
|
username: process.argv[3] || process.env.MINECRAFT_USER, |
|
|
|
|
password: process.argv[4] || process.env.MINECRAFT_PASS, |
|
|
|
|
// port: process.argv[5] || process.env.MINECRAFT_PORT || 58471,
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
const plugins = { |
|
|
|
|
command: require('./plugins/command'), |
|
|
|
|
armor: require('./plugins/armor'), |
|
|
|
|
miner: require('./plugins/miner'), |
|
|
|
|
sleeper: require('./plugins/sleeper'), |
|
|
|
|
guard: require('./plugins/guard'), |
|
|
|
|
inventory: require('./plugins/inventory'), |
|
|
|
|
statemachine: require('./plugins/statemachine'), |
|
|
|
|
finder: require('./plugins/finder'), |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cfg.plugins = plugins |
|
|
|
|
let plugins = {} |
|
|
|
|
|
|
|
|
|
function loadplugin(pluginname, pluginpath) { |
|
|
|
|
try { |
|
|
|
@ -93,13 +83,27 @@ reloadplugin = (event, filename, pluginpath) => { |
|
|
|
|
fs.watch('./lib/plugins', reloadplugin) |
|
|
|
|
|
|
|
|
|
cfg.bot = bot |
|
|
|
|
|
|
|
|
|
cfg.botAddress = new RegExp(`^${bot.username} (!.+)`) |
|
|
|
|
cfg.quiet = true |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// == actually do stuff
|
|
|
|
|
|
|
|
|
|
bot.once("spawn", () => { |
|
|
|
|
cfg.botAddress = new RegExp(`^${bot.username} (!.+)`) |
|
|
|
|
plugins = { |
|
|
|
|
command: require('./plugins/command'), |
|
|
|
|
sleeper: require('./plugins/sleeper'), |
|
|
|
|
armor: require('./plugins/armor'), |
|
|
|
|
// mover: require('./plugins/mover'),
|
|
|
|
|
guard: require('./plugins/guard'), |
|
|
|
|
inventory: require('./plugins/inventory'), |
|
|
|
|
// eater: require('./plugins/eater'),
|
|
|
|
|
finder: require('./plugins/finder'), |
|
|
|
|
miner: require('./plugins/miner'), |
|
|
|
|
// statemachine: require('./plugins/statemachine'),
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cfg.plugins = plugins |
|
|
|
|
|
|
|
|
|
for (const plugin of Object.values(plugins)) { |
|
|
|
|
try { |
|
|
|
@ -110,9 +114,10 @@ bot.once("spawn", () => { |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// bot.on("death", () => {
|
|
|
|
|
// // plugins.guard.unload()
|
|
|
|
|
// })
|
|
|
|
|
bot.on("death", () => { |
|
|
|
|
bot.pathfinder && bot.pathfinder.setGoal(null) |
|
|
|
|
// plugins.guard.unload()
|
|
|
|
|
}) |
|
|
|
|
// bot.on("respawn", () => {
|
|
|
|
|
// // setTimeout(plugins.guard.load, 2000)
|
|
|
|
|
// })
|