Commit 9c322398 authored by Big Bad Waffle's avatar Big Bad Waffle

the mod loader is now async and renamed the mod.initMain and mod.initMapo...

the mod loader is now async and renamed the mod.initMain and mod.initMapo methods to initMainThread and initMapThread
parent bf287869
......@@ -28,7 +28,7 @@ let startup = {
process.on('unhandledRejection', this.onError.bind(this));
process.on('uncaughtException', this.onError.bind(this));
mods.init();
await mods.init();
this.onModsLoaded();
},
......
......@@ -2,16 +2,16 @@ const fileLister = require('../misc/fileLister');
const events = require('../misc/events');
module.exports = {
init: function () {
init: async function () {
const modList = fileLister.getFolderList('mods');
modList.forEach(m => {
for (const m of modList) {
const mod = require('../mods/' + m + '/index');
this.onGetMod(m, mod);
});
await this.onGetMod(m, mod);
}
},
onGetMod: function (name, mod) {
onGetMod: async function (name, mod) {
if (mod.disabled)
return;
......@@ -30,13 +30,13 @@ module.exports = {
this.onGetExtra(name, mod, extra);
}
if (typeof mod.init === 'function')
await mod.init();
if (isMapThread && typeof mod.initMap === 'function')
mod.initMap();
await mod.initMapThread();
else if (!isMapThread && typeof mod.initMain === 'function')
mod.initMain();
if (typeof mod.init === 'function')
mod.init();
await mod.initMainThread();
},
onGetExtra: function (name, mod, extra) {
......
......@@ -61,13 +61,13 @@ const onCrash = async e => {
});
};
let onDbReady = function () {
let onDbReady = async function () {
require('../misc/random');
process.on('uncaughtException', onCrash);
process.on('unhandledRejection', onCrash);
mods.init();
await mods.init();
onModsReady();
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment