1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-13 10:11:50 +00:00

Prevent double registering of mods

This commit is contained in:
Edward Badel 2022-01-21 21:43:20 -05:00
parent 7741d1590e
commit 416c4f6a0e

View File

@ -135,14 +135,18 @@ export class ModLoader {
};
mods.forEach(modCode => {
modCode += `
if (typeof Mod !== 'undefined') {
if (typeof METADATA !== 'object') {
throw new Error("No METADATA variable found");
}
window.$shapez_registerMod(Mod, METADATA);
modCode += modCode.includes("window.$shapez_registerMod")
? ""
: `
if (typeof Mod !== 'undefined') {
if (typeof METADATA !== 'object') {
throw new Error("No METADATA variable found");
}
`;
window.$shapez_registerMod(Mod, METADATA);
} else {
throw new Error('No "Mod" class found')
}
`;
try {
const func = new Function(modCode);
func();