refactor(command): ♻️ refactor how mcData is loaded

`mcData` is now directly put on bot and loaded once.
It can be accessed from anywhere `bot` is accessible.
This commit is contained in:
jay 2020-12-24 17:51:44 +05:00
parent 086251bce6
commit e9f2080556

View File

@ -1,5 +1,5 @@
const v = require('vec3')
let mcData = require('minecraft-data')
let mcData
let cfg = {}
let bot = {}
@ -547,13 +547,12 @@ const load = (config) => {
cfg = config
bot = cfg.bot
mcData = mcData(bot.version)
mcData = bot.mcData || (bot.mcData = require('minecraft-data')(bot.version))
for (const [key, fn] of Object.entries(events)) {
events_registered.push(
bot.on(key, fn)
)
}
mcData = require('minecraft-data')(bot.version)
}
const unload = () => {