From 6a6c29874d807f17d5aa03b9829193f2e6e4c6cc Mon Sep 17 00:00:00 2001 From: Darien Johnson <84008186+CADIndie@users.noreply.github.com> Date: Sat, 11 May 2024 13:16:47 -0400 Subject: [PATCH] Fix Pathing Issue in MM:tm: --- src/main/java/pojlib/InstanceHandler.java | 9 ++++++--- src/main/java/pojlib/api/API_V1.java | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/pojlib/InstanceHandler.java b/src/main/java/pojlib/InstanceHandler.java index 32a911d3..7d052b9b 100644 --- a/src/main/java/pojlib/InstanceHandler.java +++ b/src/main/java/pojlib/InstanceHandler.java @@ -235,18 +235,21 @@ public static boolean removeMod(MinecraftInstances instances, MinecraftInstances ArrayList mods = Lists.newArrayList(instance.mods); mods.remove(oldInfo); instance.mods = mods.toArray(mods.toArray(new ModInfo[0])); - GsonUtils.objectToJsonFile(instance.gameDir + "/instances.json", instances); + GsonUtils.objectToJsonFile(Constants.USER_HOME + "/instances.json", instances); } return oldInfo != null; } // Return true if instance was deleted - public static boolean delete(MinecraftInstances instances, MinecraftInstances.Instance instance, String gameDir) { + public static boolean delete(MinecraftInstances instances, MinecraftInstances.Instance instance) { + File instanceDir = new File(instance.gameDir); + instanceDir.delete(); + ArrayList instances1 = Lists.newArrayList(instances.instances); instances1.remove(instance); instances.instances = instances1.toArray(new MinecraftInstances.Instance[0]); - GsonUtils.objectToJsonFile(gameDir + "/instances.json", instances); + GsonUtils.objectToJsonFile(Constants.USER_HOME + "/instances.json", instances); return true; } diff --git a/src/main/java/pojlib/api/API_V1.java b/src/main/java/pojlib/api/API_V1.java index 663c82cb..d03f3717 100644 --- a/src/main/java/pojlib/api/API_V1.java +++ b/src/main/java/pojlib/api/API_V1.java @@ -115,7 +115,7 @@ public static MinecraftInstances.Instance load(MinecraftInstances instances, Str * @return True if it deletes successfully, false otherwise. */ public static boolean deleteInstance(MinecraftInstances instances, MinecraftInstances.Instance instance) { - return InstanceHandler.delete(instances, instance, Constants.USER_HOME); + return InstanceHandler.delete(instances, instance); } /**