diff --git a/modloader.js b/modloader.js index 8f43001..74f1a82 100644 --- a/modloader.js +++ b/modloader.js @@ -63,7 +63,11 @@ globalThis.modapi_modloader = "(" + (() => { globalThis.addFileMod = async function addFileMod(mod, textContents) { const mods = await getMods(); - mods.push(mod); + if (mods.includes(mod)) { + await removeMod(mods.indexOf(mod)); + } else { + mods.push(mod); + } await saveMods(mods); const db = await getDatabase(); diff --git a/postinit.js b/postinit.js index 14e9698..fde5764 100644 --- a/postinit.js +++ b/postinit.js @@ -265,7 +265,11 @@ globalThis.modapi_postinit = "(" + (() => { "class": item || null, "hasMeta": !!item, "instanceOf": function (object) { - return ModAPI.hooks._teavm.$rt_isInstance(object, item || null); + try { + return ModAPI.hooks._teavm.$rt_isInstance(object, item || null); + } catch { + return false; + } }, "compiledName": compiledName }