Skip to content

Commit

Permalink
Fix Pathing Issue in MM:tm:
Browse files Browse the repository at this point in the history
  • Loading branch information
CADIndie committed May 11, 2024
1 parent 7aa3d0b commit 6a6c298
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/main/java/pojlib/InstanceHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,18 +235,21 @@ public static boolean removeMod(MinecraftInstances instances, MinecraftInstances
ArrayList<ModInfo> 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<MinecraftInstances.Instance> 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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/pojlib/api/API_V1.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 6a6c298

Please sign in to comment.