From 438e1d6b41040398424ea36ac311b2ba9cd5fa8e Mon Sep 17 00:00:00 2001 From: Liplum Date: Mon, 11 Dec 2023 17:35:24 +0800 Subject: [PATCH] download games into $GRADLE_USER_HOME/mindustry-mgpp/games. --- main/src/io/github/liplum/mindustry/SharedCache.kt | 13 +++++++++---- .../io/github/liplum/mindustry/task/DownloadGame.kt | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/main/src/io/github/liplum/mindustry/SharedCache.kt b/main/src/io/github/liplum/mindustry/SharedCache.kt index 3586006..627950b 100644 --- a/main/src/io/github/liplum/mindustry/SharedCache.kt +++ b/main/src/io/github/liplum/mindustry/SharedCache.kt @@ -13,12 +13,17 @@ object SharedCache { } } - fun resolveCacheDir(): File { - return resolveGradleUserHome().resolve("mindustry-mgpp") - } + val cacheDir: File + get() = resolveGradleUserHome().resolve("mindustry-mgpp") + + val modsDir: File + get() = cacheDir.resolve("mods") + + val gamesDir: File + get() = cacheDir.resolve("games") fun cleanCache() { - val dir = resolveCacheDir() + val dir = cacheDir if (dir.isDirectory) { dir.deleteRecursively() } diff --git a/main/src/io/github/liplum/mindustry/task/DownloadGame.kt b/main/src/io/github/liplum/mindustry/task/DownloadGame.kt index 52e9c1d..da404cf 100644 --- a/main/src/io/github/liplum/mindustry/task/DownloadGame.kt +++ b/main/src/io/github/liplum/mindustry/task/DownloadGame.kt @@ -51,7 +51,7 @@ open class DownloadGame : DefaultTask() { // Download is a very expensive task, it should detect whether the file exists. if (gameLoc is GitHubGameLoc) { val downloadLoc = gameLoc.createDownloadLoc() - val cacheFile = SharedCache.resolveCacheDir().resolve("github").resolve(gameLoc.fileName).ensure() + val cacheFile = SharedCache.gamesDir.resolve("github").resolve(gameLoc.fileName).ensure() if (!cacheFile.exists()) { logger.lifecycle("Downloading $downloadLoc from ${gameLoc.fileName}...") try {