From cdd427ed20bb95909c0d9af4829bf5a8ceb6d2fc Mon Sep 17 00:00:00 2001 From: ZXMushroom63 Date: Mon, 23 Dec 2024 20:19:23 +0800 Subject: [PATCH] fix stupid bug --- modloader.js | 6 +++++- postinit.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) 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 }