From cd627b03ae49963f930f487668488492f1a19fc4 Mon Sep 17 00:00:00 2001 From: azures04 Date: Sun, 11 May 2025 08:01:49 +0200 Subject: [PATCH] sync --- main.js | 2 +- modules/java.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 988880a..8a1dc32 100644 --- a/main.js +++ b/main.js @@ -448,7 +448,7 @@ async function launchGame(restartGame) { type: "release" }, forge: path.join(app.getPath("appData"), ".catboat", "forge-1.16.5.jar"), - javaPath: "C:\\Program Files\\Java\\jdk-17\\bin\\java.exe", + javaPath: await java.getPath(path.join(app.getPath("appData"), ".catboat", "jre")), memory: { min: 512, max: launcherSettings.get("ram").max diff --git a/modules/java.js b/modules/java.js index f705acd..c9bbe19 100644 --- a/modules/java.js +++ b/modules/java.js @@ -74,6 +74,21 @@ async function main(customExtractPath) { } } +async function getPath(customExtractPath) { + const requiredVersion = "17" + const isJavaInstalled = checkJavaVersion(requiredVersion) + + if (!isJavaInstalled) { + if (!fs.existsSync(path.join(customExtractPath, "jdk-17.0.12", "bin", os.platform() == "win32" ? "java.exe" : "java"))) { + await main(customExtractPath) + } else { + return path.join(customExtractPath, "jdk-17.0.12", "bin", os.platform() == "win32" ? "java.exe" : "java") + } + } else { + console.log("No further action is required.") + } +} + module.exports = { main } \ No newline at end of file