-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunBot.js
More file actions
58 lines (47 loc) · 1.58 KB
/
runBot.js
File metadata and controls
58 lines (47 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* Test harness for running a bot script locally without CAP requirements */
var mineflayer = require('mineflayer');
// var blockFinderPlugin = require('mineflayer-blockfinder')(mineflayer);
const navigatePlugin = require('mineflayer-navigate')(mineflayer);
const uuidv4 = require('uuid/v4');
const uuid = uuidv4().split('-')[0];
const host = 'localhost';
const port = 25565;
// console.log(process.argv.length)
// for (const argvElement of process.argv) {
// console.log(argvElement);
// }
if (process.argv.length < 3 || process.argv.length > 4) {
console.log('Usage : node localApp.js <script name>]')
process.exit(1)
}
const script = process.argv[2];
username = script;
username += `_${uuid}`;
username = username.substr(0,16); // trim to 16 characters, minecraft limit
var bot = mineflayer.createBot({
username,
host,
port,
version: false
})
bot.on('error', err => console.log(err))
bot.on('respawn',()=>{console.log('respawn')})
// Install the blockFinder plugin
// bot.loadPlugin(blockFinderPlugin);
// Install the navigate plugin
navigatePlugin(bot);
const playerBot = require('./' + script + '.js')
const wrapper = require('./wrapper.js')(bot)
setInterval(()=>{
playerBot.loop({
bot,
getPlayers: bot.findPlayers
}, wrapper, {})
},1000)
// Announce Team to Lewis Bot
bot.once('login', function(){
console.log(bot.username + "| playerBot: " + playerBot)
console.log(bot.username + "| Login")
console.log(bot.username + `| ${wrapper.TEAM_PREFIX}${playerBot.team}${wrapper.TEAM_SUFFIX}`)
bot.chat(`${wrapper.TEAM_PREFIX}${playerBot.team}${wrapper.TEAM_SUFFIX}`)
})