Skip to content

Commit

Permalink
Merge pull request #5 from ghostflyby/cache_dir_change
Browse files Browse the repository at this point in the history
Change the Cache directory location
  • Loading branch information
Dream-Master authored Aug 3, 2023
2 parents e887176 + af63df0 commit 983b314
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/main/java/glowredman/txloader/JarHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,27 @@ class JarHandler {

static void indexJars() {
String userHome = System.getProperty("user.home");
txloaderCache = Paths.get(userHome, "txloader");

String system = System.getProperty("os.name").toLowerCase();
if (system.contains("win")) {
String temp = System.getenv("TEMP");
String localAppData = System.getenv("LOCALAPPDATA");
if (temp != null) {
txloaderCache = Paths.get(temp, "txloader");
} else if (localAppData != null) {
txloaderCache = Paths.get(localAppData, "Temp", "txloader");
} else {
txloaderCache = Paths.get(userHome, "AppData", "Local", "Temp", "txloader");
}
} else if (system.contains("mac")) {
txloaderCache = Paths.get(userHome, "Library", "Caches", "txloader");
} else {
String xdgCacheHome = System.getenv("XDG_CACHE_HOME");
if (xdgCacheHome == null) {
txloaderCache = Paths.get(userHome, ".cache", "txloader");
} else {
txloaderCache = Paths.get(xdgCacheHome, "txloader");
}
}
List<Pair<Path, String>> clientLocations = new ArrayList<>();
clientLocations.add(Pair.of(txloaderCache, "client.jar"));
clientLocations.add(Pair.of(Paths.get(userHome, "AppData", "Roaming", ".minecraft", "versions"), "%s.jar"));
Expand Down

0 comments on commit 983b314

Please sign in to comment.