2023-12-17 14:55:27 -05:00
|
|
|
const mc = require('minecraft-protocol')
|
|
|
|
|
|
|
|
function reconnect (bot, options) {
|
|
|
|
bot.reconnectDelay = options.reconnectDelay ?? 5200 // Set from 1000 to 5200 - yfd
|
2023-12-20 11:54:03 -05:00
|
|
|
|
2023-12-26 18:45:18 -05:00
|
|
|
bot.on('end', (reason) => {
|
2023-12-17 14:55:27 -05:00
|
|
|
if (bot.reconnectDelay < 0) return
|
2023-12-24 12:11:42 -05:00
|
|
|
|
2023-12-17 14:55:27 -05:00
|
|
|
setTimeout(() => {
|
2023-12-20 11:54:03 -05:00
|
|
|
|
|
|
|
const client = options.client ?? mc.createClient(options)
|
|
|
|
bot._client = client
|
|
|
|
bot.emit('init_client', client)
|
2023-12-26 18:45:18 -05:00
|
|
|
|
2023-12-17 14:55:27 -05:00
|
|
|
}, bot.reconnectDelay)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = reconnect
|