1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-13 13:04:03 +00:00

Fixed fs-job for modloader

This commit is contained in:
DJ1TJOO 2021-03-14 16:27:16 +01:00
parent f74e296a62
commit a4632f67d0
2 changed files with 12 additions and 6 deletions

View File

@ -135,17 +135,20 @@ window.onload = async () => {
let instance = undefined; let instance = undefined;
let modFolderContents = []; let modFolderContents = [];
if (G_IS_STANDALONE) { if (G_IS_STANDALONE) {
modFolderContents = getIPCRenderer().send("fs-job", { const dirResult = await getIPCRenderer().invoke("fs-job", {
folder: "mods", folder: "mods",
type: "readDir", type: "readDir",
filename: "", filename: "",
}).data; });
if (dirResult.success) modFolderContents = dirResult.data;
if (modFolderContents.includes("modpack.json")) { if (modFolderContents.includes("modpack.json")) {
instance = getIPCRenderer().send("fs-job", { const instanceResult = await getIPCRenderer().invoke("fs-job", {
folder: "mods", folder: "mods",
type: "read", type: "read",
filename: "modpack.json", filename: "modpack.json",
}); });
if (instanceResult.success) instance = JSON.parse(instanceResult.data);
} }
} else { } else {
user = JSON.parse(localStorage.getItem("user")); user = JSON.parse(localStorage.getItem("user"));

View File

@ -91,12 +91,15 @@ export class ModManager {
*/ */
addMod(url, fromFile = false) { addMod(url, fromFile = false) {
if (fromFile && G_IS_STANDALONE) { if (fromFile && G_IS_STANDALONE) {
return new Promise((resolve, reject) => { return new Promise(async (resolve, reject) => {
const modCode = getIPCRenderer().send("fs-job", { const modCodeResult = await getIPCRenderer().invoke("fs-job", {
folder: "mods", folder: "mods",
type: "read", type: "read",
filename: url, filename: url,
}).data; });
if (!modCodeResult.success) return reject("Mod is invalid");
const modCode = modCodeResult.data;
const modScript = document.createElement("script"); const modScript = document.createElement("script");
modScript.textContent = modCode; modScript.textContent = modCode;
modScript.type = "text/javascript"; modScript.type = "text/javascript";