-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathAFK.js
215 lines (173 loc) · 6.71 KB
/
AFK.js
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
var mineflayer = require('mineflayer')
var notifier = require('node-notifier');
var bloodhoundPlugin = require('mineflayer-bloodhound')(mineflayer);
var { pathfinder, Movements } = require('mineflayer-pathfinder');
const mineflayerDashboard = require('mineflayer-dashboard');
var { GoalNear, GoalBlock, GoalXZ, GoalY, GoalInvert, GoalFollow } = require('mineflayer-pathfinder').goals
var incomingnotification
if (process.argv.length < 6 || process.argv.length > 8) {
console.log('Usage : AFK.js \x1b[31m<host>\x1b[0m')
console.log(' \x1b[31m<port>\x1b[0m')
console.log(' \x1b[31m<choose from yes/no if you want or not Windows notifications for commands like /tell or events>\x1b[0m')
console.log(' \x1b[31m<username of the owner of the bot, so the bot replies only to him>\x1b[0m')
console.log(' \x1b[32m[<name, email in case the account is premium>]\x1b[0m')
console.log(' \x1b[32m[<password, ignore in case the account is cracked>]\x1b[0m')
console.log('')
console.log(' \x1b[31mRed\x1b[0m: Needed, \x1b[32mGreen\x1b[0m: Optional')
console.log('')
console.log(' \x1b[36mExample: node AFK.js localhost 25565 no DrMoraschi\x1b[0m (this makes a cracked account bot')
console.log(' that connects to localhost and does\x1b[0m')
console.log(' not send you desktop notifications)\x1b[0m')
process.exit(1)
}
startBot()
function startBot() {
var bot = mineflayer.createBot({
host: process.argv[2],
port: parseInt(process.argv[3]),
username: process.argv[6] ? process.argv[6] : 'AFKBot',
password: process.argv[7]
})
//LOAD PLUGIN, FUNCTIONS
bot.loadPlugin(pathfinder)
var incomingnotification = process.argv[4]
var owner = process.argv[5]
bot.on('login', function() {
bot.loadPlugin(require('mineflayer-dashboard'))
})
//LOOKING
bot.once('login', function () {
setInterval(() => {
const entity = bot.nearestEntity()
if (entity !== null) {
if (entity.type === 'player') {
bot.lookAt(entity.position.offset(0, 1.6, 0))
} else if (entity.type === 'mob') {
bot.lookAt(entity.position)
}
}
}, 50)
bot.on('kicked', () => {
return
})
})
//CHAT
bot.on('whisper', (username, message, rawMessage) => {
if (message === 'follow me') {
if (username === owner) {
bot.whisper(username, 'On my way')
}} else if (message === 'stop') {
null
} else {
if (message !== 'follow me' && message !== 'stop') {
if (username !== bot.username) {
bot.whisper(username, 'Sorry, I am an AFK Bot')
bot.dashboard.log('\x1b[32m<STATUS> Correctly whispered that I am a bot','\x1b[0m')
}
}
}
if (incomingnotification === 'yes') {
if (username !== bot.username) {
if (username !== 'You') {
if (message !== 'follow me' && message !== 'stop') {
if (message !== 'Sorry, I am an AFK Bot') {
notifier.notify({
title: 'Whisper Message',
message: ('You have a new message'),
icon: 'projectlogo.jpg'
})
}
}
}
}
}
})
//KICK & ERRORS
bot.on('kicked', (reason, loggedIn) => {
bot.dashboard.log('\x1b[32m<STATUS>\x1b[0m \x1b[31mI got kicked for','\x1b[0m',reason, loggedIn)
if (incomingnotification === 'yes') {
notifier.notify({
title: 'Event Message',
message: ('I got kicked!'),
icon: 'projectlogo.jpg'
})
}
})
bot.on('kicked', () =>
setTimeout(() => {
startBot()
}, 10000)
)
//EVENTS
bot.on('death', () => {
bot.dashboard.log(`\x1b[32m<STATUS>\x1b[0m \x1b[31mI died`,'\x1b[0m')
if (incomingnotification === 'yes') {
notifier.notify({
title: 'Event Message',
message: ('I died!'),
icon: 'projectlogo.jpg'
})
}
}
)
bot.once('spawn', () => {
bot.dashboard.log(`\x1b[32m<STATUS> Correctly spawned at ${bot.entity.position}`,'\x1b[0m')
})
bot.on('respawn', () => {
bot.dashboard.log(`\x1b[32m<STATUS> Correctly respawned at ${bot.entity.position}`,'\x1b[0m')
})
bot.on('login', () => {
bot.dashboard.log('\x1b[32m<STATUS> Correctly logged in','\x1b[0m')
})
bot.once('health', () => {
bot.dashboard.log(`\x1b[32m<STATUS> I have ${bot.health} health.`,'\x1b[0m')
})
bot.on('health', () => {
if (bot.health <= 5)
bot.dashboard.log(`\x1b[32m<STATUS> \x1b[33mMy remaining health is ${bot.health}`,'\x1b[0m')
})
//WORLD
bot.once('time', () => {
setTimeout(function() {
bot.dashboard.log(`\x1b[36m<WORLD> \x1b[36mCurrent time: `+bot.time.timeOfDay,'\x1b[0m')
}, 1000)})
//PATHFIND
bot.once('spawn', () => {
const mcData = require('minecraft-data')(bot.version)
const defaultMove = new Movements(bot, mcData)
defaultMove.allowFreeMotion = true
bot.on('whisper', (username, message) => {
if (username === bot.username) return
const target = bot.players[username].entity
if (username === owner) {
if (message === 'follow me') {
bot.pathfinder.setMovements(defaultMove)
bot.pathfinder.setGoal(new GoalFollow(target, 2), true)
} else if (message === 'stop') {
bot.pathfinder.setGoal(null)
}
}
})
})
//AFK
bot.on('spawn', () => {
bot.dashboard.log('\x1b[32m<STATUS> Starting anti-AFK-kick sequence','\x1b[0m')
setInterval(() => {
setTimeout(() => {
bot.setControlState('jump', false)
}, 100);
bot.setControlState('jump', true)
}, 600000);
})
//BLOODHOUND
bloodhoundPlugin(bot);
bot.bloodhound.yaw_correlation_enabled = true;
bot.on('onCorrelateAttack', function (attacker,victim,weapon) {
if (bot.username === victim.username) {
if (weapon) {
bot.dashboard.log('\x1b[32m<STATUS>\x1b[0m \x1b[33mI got hurt by ' + (attacker.displayName|| attacker.username) + ' with a/an ' + (weapon.displayName),'\x1b[0m');
} else {
bot.dashboard.log('\x1b[32m<STATUS>\x1b[0m \x1b[33mI got hurt by ' + (attacker.displayName|| attacker.username),'\x1b[0m');
}
}});
}