diff --git a/src/main/java/pojlib/api/API_V1.java b/src/main/java/pojlib/api/API_V1.java index f84deb28..c7a2d5c0 100644 --- a/src/main/java/pojlib/api/API_V1.java +++ b/src/main/java/pojlib/api/API_V1.java @@ -62,7 +62,7 @@ public static void addMod(MinecraftInstances instances, MinecraftInstances.Insta /** * Check if an instance has a mod * - * @param instance Acquired from {@link pojlib.api.API_V1#createNewInstance(Activity, MinecraftInstances, String, String, boolean, String, String, String, String)} + * @param instance Acquired from {@link pojlib.api.API_V1#createNewInstance(Activity, MinecraftInstances, String, String, boolean, String, String)} * or {@link pojlib.api.API_V1#load(MinecraftInstances, String)} * @param name Mod name * @return True if the mod is already in the instance @@ -75,7 +75,7 @@ public static boolean hasMod(MinecraftInstances.Instance instance, String name) * Remove a mod from an instance * * @param instances Acquired from {@link pojlib.api.API_V1#loadAll(String)} - * @param instance Acquired from {@link pojlib.api.API_V1#createNewInstance(Activity, MinecraftInstances, String, String, boolean, String, String, String, String)} + * @param instance Acquired from {@link pojlib.api.API_V1#createNewInstance(Activity, MinecraftInstances, String, String, boolean, String, String)} * or {@link pojlib.api.API_V1#load(MinecraftInstances, String)} * @param gameDir .minecraft directory * @param name Mod name @@ -136,14 +136,14 @@ public static boolean deleteInstance(MinecraftInstances instances, MinecraftInst * @return A minecraft instance object * @throws IOException Throws if download of library or asset fails */ - public static MinecraftInstances.Instance createNewInstance(Activity activity, MinecraftInstances instances, String instanceName, String home, boolean useDefaultMods, String minecraftVersion, String gamePath, String modsFolderName, String imageURL) throws IOException { + public static MinecraftInstances.Instance createNewInstance(Activity activity, MinecraftInstances instances, String instanceName, String home, boolean useDefaultMods, String minecraftVersion, String imageURL) throws IOException { if(ignoreInstanceName) { - return InstanceHandler.create(activity, instances, instanceName, home, useDefaultMods, minecraftVersion, InstanceHandler.ModLoader.Fabric, gamePath, modsFolderName, imageURL); + return InstanceHandler.create(activity, instances, instanceName, home, useDefaultMods, minecraftVersion, InstanceHandler.ModLoader.Fabric, imageURL); } else if (instanceName.contains("/") || instanceName.contains("!")) { throw new IOException("You cannot use special characters (!, /, ., etc) when creating instances."); } else { - return InstanceHandler.create(activity, instances, instanceName, home, useDefaultMods, minecraftVersion, InstanceHandler.ModLoader.Fabric, gamePath, modsFolderName, imageURL); + return InstanceHandler.create(activity, instances, instanceName, home, useDefaultMods, minecraftVersion, InstanceHandler.ModLoader.Fabric, imageURL); } } @@ -161,7 +161,7 @@ public static void updateMods(MinecraftInstances instances, MinecraftInstances.I * * @param activity Android activity object * @param account Account object - * @param instance Instance object from {@link pojlib.api.API_V1#createNewInstance(Activity, MinecraftInstances, String, String, boolean, String, String, String, String)} + * @param instance Instance object from {@link pojlib.api.API_V1#createNewInstance(Activity, MinecraftInstances, String, String, boolean, String, String)} * or {@link pojlib.api.API_V1#load(MinecraftInstances, String)} */ public static void launchInstance(Activity activity, MinecraftAccount account, MinecraftInstances.Instance instance) { diff --git a/src/main/java/pojlib/instance/InstanceHandler.java b/src/main/java/pojlib/instance/InstanceHandler.java index dff39b59..b08d7181 100644 --- a/src/main/java/pojlib/instance/InstanceHandler.java +++ b/src/main/java/pojlib/instance/InstanceHandler.java @@ -7,6 +7,7 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.Locale; import pojlib.account.MinecraftAccount; import pojlib.api.API_V1; @@ -40,7 +41,7 @@ public enum ModLoader { } //creates a new instance of a minecraft version, install game + mod loader, stores non login related launch info to json - public static MinecraftInstances.Instance create(Activity activity, MinecraftInstances instances, String instanceName, String gameDir, boolean useDefaultMods, String minecraftVersion, ModLoader modLoader, String gamePath, String modsFolderName, String imageURL) { + public static MinecraftInstances.Instance create(Activity activity, MinecraftInstances instances, String instanceName, String gameDir, boolean useDefaultMods, String minecraftVersion, ModLoader modLoader, String imageURL) { API_V1.finishedDownloading = false; File instancesFile = new File(gameDir + "/instances.json"); if (instancesFile.exists()) { @@ -58,12 +59,12 @@ public static MinecraftInstances.Instance create(Activity activity, MinecraftIns instance.instanceName = instanceName; instance.instanceImageURL = imageURL; instance.versionName = minecraftVersion; - instance.gameDir = gamePath; + instance.gameDir = Constants.USER_HOME + "/" + instanceName.toLowerCase(Locale.ROOT).replaceAll(" ", "_"); instance.defaultMods = useDefaultMods; - if(modsFolderName != null) { - instance.modsDirName = modsFolderName; - } else { - instance.modsDirName = instance.versionName; + + File gameDirFile = new File(instance.gameDir); + if(!gameDirFile.exists()) { + gameDirFile.mkdirs(); } VersionInfo modLoaderVersionInfo = null; @@ -176,7 +177,7 @@ public static boolean removeMod(MinecraftInstances instances, MinecraftInstances if(oldInfo != null) { // Delete the mod - File modFile = new File(gameDir + "/mods/" + instance.modsDirName + "/" + name + ".jar"); + File modFile = new File(gameDir + "/mods/" + name + ".jar"); modFile.delete(); ArrayList mods = Lists.newArrayList(instance.mods); diff --git a/src/main/java/pojlib/instance/MinecraftInstances.java b/src/main/java/pojlib/instance/MinecraftInstances.java index 92c45790..f362577c 100644 --- a/src/main/java/pojlib/instance/MinecraftInstances.java +++ b/src/main/java/pojlib/instance/MinecraftInstances.java @@ -38,7 +38,6 @@ public static class Instance { public String instanceName; public String instanceImageURL; public String versionName; - public String modsDirName; public String versionType; public String classpath; public String gameDir; @@ -95,17 +94,17 @@ public void updateMods(MinecraftInstances instances) { assert version != null; - File modsDir = new File(gameDir + "/mods/" + modsDirName); + File modsDir = new File(gameDir + "/mods"); if(!modsDir.exists()) { ArrayList modInfos = new ArrayList<>(); for(ModInfo info : version.coreMods) { - File mod = new File(gameDir + "/mods/" + modsDirName + "/" + info.slug + ".jar"); + File mod = new File(modsDir + "/" + info.slug + ".jar"); DownloadUtils.downloadFile(info.download_link, mod); modInfos.add(info); } if(defaultMods) { for (ModInfo info : version.defaultMods) { - File mod = new File(gameDir + "/mods/" + modsDirName + "/" + info.slug + ".jar"); + File mod = new File(modsDir + "/" + info.slug + ".jar"); DownloadUtils.downloadFile(info.download_link, mod); modInfos.add(info); } @@ -125,7 +124,7 @@ public void updateMods(MinecraftInstances instances) { continue; } - File mod = new File(gameDir + "/mods/" + modsDirName + "/" + info.slug + ".jar"); + File mod = new File(modsDir + "/" + info.slug + ".jar"); DownloadUtils.downloadFile(info.download_link, mod); info = currInfo; } @@ -141,7 +140,7 @@ public void updateMods(MinecraftInstances instances) { continue; } - File mod = new File(gameDir + "/mods/" + modsDirName + "/" + info.slug + ".jar"); + File mod = new File(modsDir + "/" + info.slug + ".jar"); DownloadUtils.downloadFile(info.download_link, mod); info = currInfo; } @@ -150,7 +149,7 @@ public void updateMods(MinecraftInstances instances) { // Download custom mods for(ModInfo currInfo : mods) { - File mod = new File(gameDir + "/mods/" + modsDirName + "/" + currInfo.slug + ".jar"); + File mod = new File(modsDir + "/" + currInfo.slug + ".jar"); if(!mod.exists()) { DownloadUtils.downloadFile(currInfo.download_link, mod); } diff --git a/src/main/java/pojlib/util/JREUtils.java b/src/main/java/pojlib/util/JREUtils.java index a74c271c..19b457c2 100644 --- a/src/main/java/pojlib/util/JREUtils.java +++ b/src/main/java/pojlib/util/JREUtils.java @@ -200,7 +200,6 @@ public static int launchJavaVM(final Activity activity, final List JVMAr userArgs.add("-Dorg.lwjgl.opengl.libname=" + graphicsLib); userArgs.add("-Dorg.lwjgl.opengles.libname=" + "/system/lib64/libGLESv3.so"); userArgs.add("-Dorg.lwjgl.egl.libname=" + "/system/lib64/libEGL_dri.so"); - userArgs.add("-Dfabric.addMods=" + instance.gameDir + "/mods/" + instance.modsDirName); userArgs.addAll(JVMArgs); System.out.println(JVMArgs);