1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-16 03:31:52 +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 => { mods.forEach(modCode => {
modCode += ` modCode += modCode.includes("window.$shapez_registerMod")
if (typeof Mod !== 'undefined') { ? ""
if (typeof METADATA !== 'object') { : `
throw new Error("No METADATA variable found"); if (typeof Mod !== 'undefined') {
} if (typeof METADATA !== 'object') {
window.$shapez_registerMod(Mod, METADATA); throw new Error("No METADATA variable found");
} }
`; window.$shapez_registerMod(Mod, METADATA);
} else {
throw new Error('No "Mod" class found')
}
`;
try { try {
const func = new Function(modCode); const func = new Function(modCode);
func(); func();