From e9f2080556f0079afad7042df268eb00177118c0 Mon Sep 17 00:00:00 2001 From: jay Date: Thu, 24 Dec 2020 17:51:44 +0500 Subject: [PATCH] refactor(command): :recycle: refactor how mcData is loaded `mcData` is now directly put on bot and loaded once. It can be accessed from anywhere `bot` is accessible. --- lib/plugins/command.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/plugins/command.js b/lib/plugins/command.js index 3085e3d..fc5b443 100644 --- a/lib/plugins/command.js +++ b/lib/plugins/command.js @@ -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 = () => {