1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-17 04:01:51 +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

@ -117,7 +117,23 @@ export class ModLoader {
); );
} }
mods.push(await response.text()); 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 = mods.concat(json.mods);
} }
window.$shapez_registerMod = (modClass, meta) => { window.$shapez_registerMod = (modClass, meta) => {