From 6663f382419e069c9c97dcfadd254e6be826c434 Mon Sep 17 00:00:00 2001 From: Gravita Date: Tue, 22 Mar 2022 15:36:26 +0700 Subject: [PATCH] [FEATURE] LwjglDownloadCommand, modules and modulePath --- .../client/ClientLauncherProcess.java | 21 +++++++++++++------ .../launcher/profiles/ClientProfile.java | 17 ++++++++++++++- .../profiles/ClientProfileBuilder.java | 14 ++++++++++++- modules | 2 +- 4 files changed, 45 insertions(+), 9 deletions(-) diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java index 2f51f73b..ecd35d1f 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java @@ -20,6 +20,7 @@ import pro.gravit.utils.Version; import pro.gravit.utils.helper.*; +import java.io.File; import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; @@ -33,7 +34,7 @@ public class ClientLauncherProcess { public final ClientParams params = new ClientParams(); public final List jvmArgs = new LinkedList<>(); public final List jvmModules = new LinkedList<>(); - public final List jvmModulesPaths = new LinkedList<>(); + public final List jvmModulesPaths = new LinkedList<>(); public final List systemClientArgs = new LinkedList<>(); public final List systemClassPath = new LinkedList<>(); public final Map systemEnv = new HashMap<>(); @@ -127,7 +128,8 @@ private void applyClientProfile() { this.params.oauthExpiredTime = Request.getTokenExpiredTime(); this.params.extendedTokens = Request.getExtendedTokens(); } - + this.jvmModules.addAll(this.params.profile.getModules()); + this.jvmModulesPaths.addAll(this.params.profile.getModulePath()); if (this.params.profile.getRuntimeInClientConfig() != ClientProfile.RuntimeInClientConfig.NONE) { jvmModules.add("javafx.base"); jvmModules.add("javafx.graphics"); @@ -137,6 +139,7 @@ private void applyClientProfile() { jvmModules.add("javafx.media"); jvmModules.add("javafx.web"); } + LauncherEngine.modulesManager.invokeEvent(new ClientProcessBuilderCreateEvent(this)); } @@ -187,20 +190,26 @@ public void start(boolean pipeOutput) throws IOException, InterruptedException { } private void applyJava9Params(List processArgs) { - jvmModulesPaths.add(javaVersion.jvmDir); + /*jvmModulesPaths.add(javaVersion.jvmDir); jvmModulesPaths.add(javaVersion.jvmDir.resolve("jre")); Path openjfxPath = JavaHelper.tryGetOpenJFXPath(javaVersion.jvmDir); if (openjfxPath != null) { jvmModulesPaths.add(openjfxPath); - } + }*/ // TODO: fix runtime in client StringBuilder modulesPath = new StringBuilder(); StringBuilder modulesAdd = new StringBuilder(); for (String moduleName : jvmModules) { - boolean success = JavaHelper.tryAddModule(jvmModulesPaths, moduleName, modulesPath); + /*boolean success = JavaHelper.tryAddModule(jvmModulesPaths, moduleName, modulesPath); if (success) { if (modulesAdd.length() > 0) modulesAdd.append(","); modulesAdd.append(moduleName); - } + }*/ + if (modulesAdd.length() > 0) modulesAdd.append(","); + modulesAdd.append(moduleName); + } + for(String modulePath : jvmModulesPaths) { + if (modulesPath.length() > 0) modulesPath.append(File.pathSeparator); + modulesPath.append(modulePath); } if (modulesAdd.length() > 0) { processArgs.add("--add-modules"); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java index 89a1d4d4..b3fa2761 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java @@ -48,6 +48,10 @@ public final class ClientProfile implements Comparable { @LauncherNetworkAPI private List classPath; @LauncherNetworkAPI + private List modulePath; + @LauncherNetworkAPI + private List modules; + @LauncherNetworkAPI private List altClassPath; @LauncherNetworkAPI private List clientArgs; @@ -91,6 +95,7 @@ public ClientProfile() { updateOptional = new HashSet<>(); jvmArgs = new ArrayList<>(); classPath = new ArrayList<>(); + modulePath = new ArrayList<>(); altClassPath = new ArrayList<>(); clientArgs = new ArrayList<>(); compatClasses = new ArrayList<>(); @@ -102,7 +107,7 @@ public ClientProfile() { runtimeInClientConfig = RuntimeInClientConfig.NONE; } - public ClientProfile(List update, List updateExclusions, List updateShared, List updateVerify, Set updateOptional, List jvmArgs, List classPath, List altClassPath, List clientArgs, List compatClasses, Map properties, List servers, SecurityManagerConfig securityManagerConfig, ClassLoaderConfig classLoaderConfig, SignedClientConfig signedClientConfig, RuntimeInClientConfig runtimeInClientConfig, String version, String assetIndex, String dir, String assetDir, int recommendJavaVersion, int minJavaVersion, int maxJavaVersion, boolean warnMissJavaVersion, ProfileDefaultSettings settings, int sortIndex, UUID uuid, String title, String info, boolean updateFastCheck, String mainClass) { + public ClientProfile(List update, List updateExclusions, List updateShared, List updateVerify, Set updateOptional, List jvmArgs, List classPath, List modulePath, List modules, List altClassPath, List clientArgs, List compatClasses, Map properties, List servers, SecurityManagerConfig securityManagerConfig, ClassLoaderConfig classLoaderConfig, SignedClientConfig signedClientConfig, RuntimeInClientConfig runtimeInClientConfig, String version, String assetIndex, String dir, String assetDir, int recommendJavaVersion, int minJavaVersion, int maxJavaVersion, boolean warnMissJavaVersion, ProfileDefaultSettings settings, int sortIndex, UUID uuid, String title, String info, boolean updateFastCheck, String mainClass) { this.update = update; this.updateExclusions = updateExclusions; this.updateShared = updateShared; @@ -110,6 +115,8 @@ public ClientProfile(List update, List updateExclusions, List getModulePath() { + return Collections.unmodifiableList(modulePath); + } + + public List getModules() { + return Collections.unmodifiableList(modules); + } + public String[] getAlternativeClassPath() { return altClassPath.toArray(new String[0]); } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfileBuilder.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfileBuilder.java index 32a17dd6..052e2f67 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfileBuilder.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfileBuilder.java @@ -12,6 +12,8 @@ public class ClientProfileBuilder { private Set updateOptional = new HashSet<>(); private List jvmArgs = new ArrayList<>(); private List classPath = new ArrayList<>(); + private List modulePath = new ArrayList<>(); + private List modules = new ArrayList<>(); private List altClassPath = new ArrayList<>(); private List clientArgs = new ArrayList<>(); private List compatClasses = new ArrayList<>(); @@ -142,6 +144,16 @@ public ClientProfileBuilder setRecommendJavaVersion(int recommendJavaVersion) { return this; } + public ClientProfileBuilder setModulePath(List modulePath) { + this.modulePath = modulePath; + return this; + } + + public ClientProfileBuilder setModules(List modules) { + this.modules = modules; + return this; + } + public ClientProfileBuilder setMinJavaVersion(int minJavaVersion) { this.minJavaVersion = minJavaVersion; return this; @@ -193,6 +205,6 @@ public ClientProfileBuilder setMainClass(String mainClass) { } public ClientProfile createClientProfile() { - return new ClientProfile(update, updateExclusions, updateShared, updateVerify, updateOptional, jvmArgs, classPath, altClassPath, clientArgs, compatClasses, properties, servers, securityManagerConfig, classLoaderConfig, signedClientConfig, runtimeInClientConfig, version, assetIndex, dir, assetDir, recommendJavaVersion, minJavaVersion, maxJavaVersion, warnMissJavaVersion, settings, sortIndex, uuid, title, info, updateFastCheck, mainClass); + return new ClientProfile(update, updateExclusions, updateShared, updateVerify, updateOptional, jvmArgs, classPath, modulePath, modules, altClassPath, clientArgs, compatClasses, properties, servers, securityManagerConfig, classLoaderConfig, signedClientConfig, runtimeInClientConfig, version, assetIndex, dir, assetDir, recommendJavaVersion, minJavaVersion, maxJavaVersion, warnMissJavaVersion, settings, sortIndex, uuid, title, info, updateFastCheck, mainClass); } } \ No newline at end of file diff --git a/modules b/modules index aea93d68..a1318b09 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit aea93d6803e4770f23ff4a2ea4b5f8752d053d8b +Subproject commit a1318b09c1f5657ad60eaee362746cd493d38c8a