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

Allow external URL to load more than one mod

Instead of loading the text returned from the remote server, load a JSON object with a `mods` field, containing strings of all the mods. This lets us work on more than one mod at a time or without separate repos. This will break tooling such as `create-shapezio-mod` though.
This commit is contained in:
Bagel03 2022-01-18 11:12:23 -05:00 committed by GitHub
parent 9311ffe4e3
commit 0141df1abf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -116,8 +116,24 @@ export class ModLoader {
response.statusText
);
}
let json;
try {
json = await response.json();
} catch (e) {
throw new Error(
"Failed to parse JSON object from " +
globalConfig.debug.externalModUrl +
": " +
e
);
}
if(json.mods === undefined) {
throw new Error("Failed to load " + globalConfig.debug.externalModUrl + ": No 'mods' field in json object");
}
mods.push(await response.text());
mods = mods.concat(json.mods);
}
window.$shapez_registerMod = (modClass, meta) => {