forked from Jason54jg/Slime-AFK
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
75 lines (70 loc) · 3.3 KB
/
index.js
File metadata and controls
75 lines (70 loc) · 3.3 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
const mineflayer = require("mineflayer");
const log = (...args) => require("process").stdout.write((config.bot.logTime ? `<${new Date(Date.now()).toLocaleTimeString()}> ` : "") + args.join("") + "[0m\n");
const config = require("./config.json");
const bot = mineflayer.createBot({
host: config.server.ip,
port: config.server.port,
username: config.account.username,
version: "1.8.9",
auth: "microsoft",
})
bot.on('windowOpen', (window) => {
setTimeout(() => {
const playerHeads = window.slots
.filter(slot => slot !== null && slot.displayName === 'Head')
if (playerHeads.length > 0) {
const mouseButton = 0; // 0: left click, 1: right click
const mode = 0; // 0: single click
console.log(playerHeads)
console.log(playerHeads[0])
console.log(playerHeads[0].slot)
bot.clickWindow(playerHeads[0].slot, mouseButton, mode);
}
else{
console.log("pas de player head trouvé, voici la liste des items")
window.slots.forEach((slot, index) => {
if (slot) {
console.log(`Case ${index}: ${slot.displayName}`);
} //else {
//console.log(`Case ${index}: Vide`);
//}
});
}
}, 5000);
});
const limbo = () => {
Array.from(Array(1)).forEach(() => setTimeout(() => bot.chat("/skyblock"), 3000));
}
bot.once("login", () => log(`Le ${bot.username} a rejoint le serveur.`))
bot.on("message", event => {
let message = event.toString().trim();
if (message.endsWith(' the lobby!') || message.endsWith(' the lobby! <<<')) limbo();
if (message.includes("You were spawned in Limbo.")) log("[32mSuccessfully spawned in Limbo.");
if (message.includes("An exception occurred in your connection, so you were put in the SkyBlock Lobby!") || message.includes("Out of sync, check your internet connection!")) {
log(`Problème de connexion au serveur (${bot.username})`);
setTimeout(() => bot.chat("/skyblock"), 70000);
setTimeout(() => bot.chat("/visit "+config.visit.username), 80000);
}
if (message.includes("[Important] This server will restart soon: Scheduled Restart")) {
log(`[Important] Ce serveur va bientôt redémarrer: Redémarrage planifié (${bot.username})`);
setTimeout(() => bot.chat("/skyblock"), 70000);
setTimeout(() => bot.chat("/visit "+config.visit.username), 80000);
}
if (message.includes("This server will restart soon: Game Update")) {
log(`Ce serveur va bientôt redémarrer: mise à jour du jeu (${bot.username})`);
setTimeout(() => bot.chat("/skyblock"), 40000);
setTimeout(() => bot.chat("/visit "+config.visit.username), 42000);
}
if (message.includes("Evacuating to Hub...")) {
log(`Évacuation vers le hub (${bot.username})`);
setTimeout(() => bot.chat("/visit "+config.visit.username), 10000);
}
if (message.includes("Sending to server")) {
log(`Envoi au serveur (${bot.username})`);
setTimeout(() => bot.chat("/visit "+config.visit.username), 10000);
}
if (message.includes("Warping you to your SkyBlock island...")) {
log(`Vous téléporte sur votre île SkyBlock (${bot.username})`);
}
if (config.bot.logAllMessages) log(message);
});