2024-07-20 20:27:17 -04:00
|
|
|
const mc = require('minecraft-protocol');
|
|
|
|
const usernameGen = require("../util/usernameGen");
|
|
|
|
function reconnect (bot, options, config) {
|
2024-07-07 15:44:16 -04:00
|
|
|
bot.on('end', () => {
|
|
|
|
if (bot.reconnectDelay < 0) return
|
2024-07-20 20:27:17 -04:00
|
|
|
setTimeout(() => {
|
|
|
|
if (options.usernameGen) {
|
2024-10-07 09:58:32 -04:00
|
|
|
client = options.client ?? mc.createClient(options, bot.options.username = usernameGen(bot))
|
2024-07-20 20:27:17 -04:00
|
|
|
} else {
|
|
|
|
client = options.client ?? mc.createClient(options)
|
|
|
|
}
|
|
|
|
bot._client = client
|
|
|
|
bot.emit('init_client', bot._client)
|
|
|
|
}, options.reconnectDelay);
|
2024-07-07 15:44:16 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = reconnect;
|