1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-02-12 02:49:20 +00:00

Update modloader.js

This commit is contained in:
Bagel03 2022-01-18 16:37:39 -05:00 committed by GitHub
parent 0141df1abf
commit 38ff201670
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -103,37 +103,25 @@ export class ModLoader {
mods = await ipcRenderer.invoke("get-mods"); mods = await ipcRenderer.invoke("get-mods");
} }
if (G_IS_DEV && globalConfig.debug.externalModUrl) { if (G_IS_DEV && globalConfig.debug.externalModUrl) {
const response = await fetch(globalConfig.debug.externalModUrl, { let modURLs = Array.isArray(globalConfig.debug.externalModUrl) ?
method: "GET", globalConfig.debug.externalModUrl : [globalConfig.debug.externalModUrl];
});
if (response.status !== 200) {
throw new Error(
"Failed to load " +
globalConfig.debug.externalModUrl +
": " +
response.status +
" " +
response.statusText
);
}
let json; for(let i = 0; i < modURLs.length; i++) {
try { const response = await fetch(modURLs[i], {
json = await response.json(); method: "GET",
} catch (e) { });
throw new Error( if (response.status !== 200) {
"Failed to parse JSON object from " + throw new Error(
globalConfig.debug.externalModUrl + "Failed to load " +
": " + modURLs[i] +
e ": " +
); response.status +
" " +
response.statusText
);
}
mods.push(await response.text());
} }
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) => {