File size: 3,725 Bytes
73b0b6d |
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 |
const mineflayer = require('mineflayer');
const fs = require('fs');
const pathfinder = require('mineflayer-pathfinder').pathfinder;
const { GoalNear } = require('mineflayer-pathfinder').goals;
const config = {
host: "minegens.id",
port: 25565,
version: "1.20.1"
};
// Daftar akun bot
const botAccounts = [
//{ username: "RenTakamori", password: "Kyouka19" },
// { username: "SenjoHutagi", password: "RenTakamori00", command: "/is" },
//{ username: "GunturKzy", password: "RenTakamori00", command: "/is" },
{ username: "KuroYamiis", password: "KuroID991", command: "/afk" },
];
const databaseFile = 'database.json';
let userDatabase = {};
if (fs.existsSync(databaseFile)) {
userDatabase = JSON.parse(fs.readFileSync(databaseFile, 'utf8'));
}
function createBot(account, delay) {
setTimeout(() => {
const bot = mineflayer.createBot({
host: config.host,
port: config.port,
username: account.username,
version: config.version,
});
bot.loadPlugin(pathfinder);
bot.once('login', () => {
console.log(`Bot ${bot.username} berhasil masuk`);
});
bot.once('spawn', () => {
console.log(`Bot ${bot.username} telah spawn`);
setTimeout(() => {
if (!userDatabase[account.username]) {
bot.chat(`/register ${account.password}`);
userDatabase[account.username] = true;
fs.writeFileSync(databaseFile, JSON.stringify(userDatabase, null, 2));
console.log(`Mendaftarkan akun ${account.username}`);
} else {
bot.chat(`/login ${account.password}`);
console.log(`Login sebagai ${account.username}`);
}
}, 5000);
setTimeout(() => {
bot.chat('/server tycoon');
console.log(`Bot ${account.username} masuk ke realm Tycoon`);
}, 10000);
setTimeout(() => {
bot.chat(`${account.command}`);
console.log(`Bot ${account.username} command ${account.command}`);
}, 17000);
setTimeout(() => {
bot.chat('/spin');
console.log(`Bot ${account.username} Berputar`);
}, 19000);
const messages = [
"ヽ(・∀・)ノ",
"(^▽^)",
"(*^‿^*)",
"(≧◡≦)",
"(⁀ᗢ⁀)",
"╰(°▽°)╯",
"(✿◕‿◕)",
"(o^▽^o)",
"(。♥‿♥。)",
"(~‾▿‾)~"
];
function getRandomMessage() {
return messages[Math.floor(Math.random() * messages.length)];
}
// function randomChat() {
// bot.chat('/spin');
// }
// setInterval(randomChat, 420000);
});
bot.on('message', (message) => {
const text = message.toAnsi();
if (!text.includes("Level Progress:") && !text.includes("Next Rewards in")) {
console.log(`Bot ${bot.username} | ${text}`);
}
});
bot.once('kicked', (reason) => {
console.log(`Bot ${bot.username} dikeluarkan: ${reason}`);
reconnect(bot, account);
});
bot.once('error', (err) => {
console.error(`Terjadi kesalahan pada ${bot.username}: ${err}`);
reconnect(bot, account);
});
bot.once('death', () => {
console.log(`Bot ${bot.username} mati, respawning...`);
setTimeout(() => bot.chat('/respawn'), 5000);
});
}, delay);
}
function reconnect(bot, account) {
console.log(`Bot ${account.username} mencoba untuk masuk kembali...`);
bot.end(); // Pastikan instance lama dihentikan sebelum reconnect
setTimeout(() => createBot(account, 5000), 5000);
}
// Jalankan semua bot dengan delay 15 detik antar akun
botAccounts.forEach((account, index) => {
createBot(account, index * 60000);
});
|