2024-02-19 04:15:45 -06:00
|
|
|
package net.eaglerforge.api;
|
|
|
|
|
|
|
|
import org.teavm.jso.JSBody;
|
|
|
|
|
|
|
|
public class ModLoader {
|
|
|
|
public static String[] Mods = {};
|
|
|
|
|
2024-08-01 12:46:39 -05:00
|
|
|
@JSBody(params = { "Mods" }, script = "globalThis.ModLoader(Mods);")
|
2024-02-19 04:15:45 -06:00
|
|
|
public static native void loadMods(String[] Mods);
|
|
|
|
|
|
|
|
@JSBody(params = {}, script = "loadLoader();")
|
|
|
|
public static native void loadLoader();
|
|
|
|
|
|
|
|
@JSBody(params = { "Mods" }, script = "localStorage.setItem('ml::Mods', JSON.stringify(Mods))")
|
|
|
|
private static native void saveMods(String[] Mods);
|
|
|
|
|
|
|
|
@JSBody(params = {}, script = "try { return JSON.parse(localStorage.getItem('ml::Mods')||'[]') } catch(err) {return []}")
|
|
|
|
private static native String[] retrieveMods();
|
|
|
|
|
2024-08-01 12:46:39 -05:00
|
|
|
@JSBody(params = {}, script = "return (returnTotalLoadedMods || (()=>{return 0}))();")
|
|
|
|
public static native int returnTotalLoadedMods();
|
2024-02-22 07:09:44 -06:00
|
|
|
|
|
|
|
|
2024-02-19 04:15:45 -06:00
|
|
|
public static void saveModsToLocalStorage() {
|
|
|
|
saveMods(Mods);
|
|
|
|
};
|
|
|
|
|
|
|
|
public static void loadModsFromLocalStorage() {
|
|
|
|
Mods = retrieveMods();
|
|
|
|
};
|
|
|
|
}
|