From 0cc47a7b062755dc7b08d534c9d25b594c02e693 Mon Sep 17 00:00:00 2001 From: Gravita Date: Fri, 9 Jul 2021 17:18:29 +0700 Subject: [PATCH] [FIX] JavaHelper Windows --- .../java/pro/gravit/launchserver/LaunchServer.java | 3 +-- .../java/pro/gravit/utils/helper/IOHelper.java | 14 ++++++++++++++ .../java/pro/gravit/utils/helper/JavaHelper.java | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index 96081c10..97619788 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -177,8 +177,7 @@ public LaunchServer(LaunchServerDirectories directories, LaunchServerEnv env, La authManager = new AuthManager(this); updatesManager = new UpdatesManager(this); RestoreResponse.registerProviders(this); - //Generate or set new Certificate API - certificateManager.orgName = config.projectName; + config.init(ReloadType.FULL); registerObject("launchServer", this); GarbageManager.registerNeedGC(sessionManager); diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/IOHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/IOHelper.java index d4218e8f..81826539 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/IOHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/IOHelper.java @@ -137,6 +137,20 @@ public static String getIP(SocketAddress address) { return ((InetSocketAddress) address).getAddress().getHostAddress(); } + public static Path getRoot() { + switch (JVMHelper.OS_TYPE) { + case MUSTDIE: { + String drive = System.getenv("SystemDrive"); + return Paths.get(drive); + } + case LINUX: + case MACOSX: { + return Paths.get("/"); + } + } + throw new UnsupportedOperationException(); + } + public static byte[] getResourceBytes(String name) throws IOException { return read(getResourceURL(name)); } diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/JavaHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/JavaHelper.java index d4d75f69..ba81ac82 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/JavaHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/JavaHelper.java @@ -78,7 +78,7 @@ public static List findJava() { } } if (JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE) { - Path rootDrive = Paths.get(System.getProperty("java.home")); + Path rootDrive = IOHelper.getRoot(); try { trySearchJava(javaPaths, result, rootDrive.resolve("Program Files").resolve("Java")); trySearchJava(javaPaths, result, rootDrive.resolve("Program Files").resolve("AdoptOpenJDK"));