From 831489a1b3393c208cc223c54a36cca02860c076 Mon Sep 17 00:00:00 2001 From: Gravita <12893402+gravit0@users.noreply.github.com> Date: Fri, 20 Jan 2023 19:29:27 +0700 Subject: [PATCH 1/5] [FIX] Java 32/64 --- .../gui/scenes/settings/SettingsScene.java | 17 +++++++++++++++-- .../client/gui/service/JavaService.java | 12 +++++++++++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/main/java/pro/gravit/launcher/client/gui/scenes/settings/SettingsScene.java b/src/main/java/pro/gravit/launcher/client/gui/scenes/settings/SettingsScene.java index 561be711..c574ae7d 100644 --- a/src/main/java/pro/gravit/launcher/client/gui/scenes/settings/SettingsScene.java +++ b/src/main/java/pro/gravit/launcher/client/gui/scenes/settings/SettingsScene.java @@ -16,6 +16,7 @@ import pro.gravit.launcher.client.gui.stage.ConsoleStage; import pro.gravit.launcher.profiles.ClientProfile; import pro.gravit.utils.helper.IOHelper; +import pro.gravit.utils.helper.JVMHelper; import pro.gravit.utils.helper.LogHelper; import java.io.File; @@ -25,6 +26,9 @@ import java.util.function.Consumer; public class SettingsScene extends AbstractScene { + + private final static long MAX_JAVA_MEMORY_X64 = 32*1024; + private final static long MAX_JAVA_MEMORY_X32 = 1536; private Pane componentList; private Label ramLabel; private Slider ramSlider; @@ -52,12 +56,14 @@ protected void doInit() { ramSlider = LookupHelper.lookup(layout, "#ramSlider"); ramLabel = LookupHelper.lookup(layout, "#ramLabel"); + long maxSystemMemory; try { SystemInfo systemInfo = new SystemInfo(); - ramSlider.setMax(systemInfo.getHardware().getMemory().getTotal() >> 20); + maxSystemMemory =(systemInfo.getHardware().getMemory().getTotal() >> 20); } catch (Throwable e) { - ramSlider.setMax(2048); + maxSystemMemory = 2048; } + ramSlider.setMax(Math.min(maxSystemMemory, getJavaMaxMemory())); ramSlider.setSnapToTicks(true); ramSlider.setShowTickMarks(true); @@ -131,6 +137,13 @@ public Double fromString(String string) { reset(); } + private long getJavaMaxMemory() { + if(application.javaService.isArchAvailable(JVMHelper.ARCH.X86_64) || application.javaService.isArchAvailable(JVMHelper.ARCH.ARM64)) { + return MAX_JAVA_MEMORY_X64; + } + return MAX_JAVA_MEMORY_X32; + } + @Override public void reset() { profileSettings = new RuntimeSettings.ProfileSettingsView(application.getProfileSettings()); diff --git a/src/main/java/pro/gravit/launcher/client/gui/service/JavaService.java b/src/main/java/pro/gravit/launcher/client/gui/service/JavaService.java index b6a4dd4a..a86f7128 100644 --- a/src/main/java/pro/gravit/launcher/client/gui/service/JavaService.java +++ b/src/main/java/pro/gravit/launcher/client/gui/service/JavaService.java @@ -30,7 +30,7 @@ public JavaService(JavaFXApplication application) { int build = Integer.parseInt(matcher.group("build")); JVMHelper.ARCH arch = JVMHelper.ARCH.valueOf(matcher.group("arch")); boolean javafx = Boolean.parseBoolean(matcher.group("javafx")); - if (arch != JVMHelper.ARCH_TYPE) { + if (!isArchAvailable(arch)) { continue; } if(!JVMHelper.OS_TYPE.name.equals(os)) { @@ -52,6 +52,16 @@ public JavaService(JavaFXApplication application) { javaVersions = Collections.unmodifiableList(versions); } + public boolean isArchAvailable(JVMHelper.ARCH arch) { + if(JVMHelper.ARCH_TYPE == arch) { + return true; + } + if(arch == JVMHelper.ARCH.X86_64 && JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE && !JVMHelper.isJVMMatchesSystemArch()) { + return true; + } + return false; + } + public boolean isIncompatibleJava(JavaHelper.JavaVersion version, ClientProfile profile) { return version.version > profile.getMaxJavaVersion() || version.version < profile.getMinJavaVersion() || (!version.enabledJavaFX && profile.getRuntimeInClientConfig() != ClientProfile.RuntimeInClientConfig.NONE) From ac251d05819c5024897ca0a22a524d0a0b5cd566 Mon Sep 17 00:00:00 2001 From: Gravita <12893402+gravit0@users.noreply.github.com> Date: Fri, 20 Jan 2023 19:34:44 +0700 Subject: [PATCH 2/5] [FIX] Java 32/64 in ARM --- .../pro/gravit/launcher/client/gui/service/JavaService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/pro/gravit/launcher/client/gui/service/JavaService.java b/src/main/java/pro/gravit/launcher/client/gui/service/JavaService.java index a86f7128..5e99aa3f 100644 --- a/src/main/java/pro/gravit/launcher/client/gui/service/JavaService.java +++ b/src/main/java/pro/gravit/launcher/client/gui/service/JavaService.java @@ -56,7 +56,8 @@ public boolean isArchAvailable(JVMHelper.ARCH arch) { if(JVMHelper.ARCH_TYPE == arch) { return true; } - if(arch == JVMHelper.ARCH.X86_64 && JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE && !JVMHelper.isJVMMatchesSystemArch()) { + if(arch == JVMHelper.ARCH.X86_64 && JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE && + (( JVMHelper.ARCH_TYPE == JVMHelper.ARCH.X86 && !JVMHelper.isJVMMatchesSystemArch()) || JVMHelper.ARCH_TYPE == JVMHelper.ARCH.ARM64)) { return true; } return false; From 902c3b7ba429969fa33ca8b05a63e7b3aa18f013 Mon Sep 17 00:00:00 2001 From: Gravita <12893402+gravit0@users.noreply.github.com> Date: Fri, 20 Jan 2023 19:37:02 +0700 Subject: [PATCH 3/5] [FIX] Java 32/64 in MacOS --- .../pro/gravit/launcher/client/gui/service/JavaService.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/pro/gravit/launcher/client/gui/service/JavaService.java b/src/main/java/pro/gravit/launcher/client/gui/service/JavaService.java index 5e99aa3f..0b979248 100644 --- a/src/main/java/pro/gravit/launcher/client/gui/service/JavaService.java +++ b/src/main/java/pro/gravit/launcher/client/gui/service/JavaService.java @@ -60,6 +60,9 @@ public boolean isArchAvailable(JVMHelper.ARCH arch) { (( JVMHelper.ARCH_TYPE == JVMHelper.ARCH.X86 && !JVMHelper.isJVMMatchesSystemArch()) || JVMHelper.ARCH_TYPE == JVMHelper.ARCH.ARM64)) { return true; } + if(arch == JVMHelper.ARCH.X86_64 && JVMHelper.OS_TYPE == JVMHelper.OS.MACOSX && JVMHelper.ARCH_TYPE == JVMHelper.ARCH.ARM64) { + return true; + } return false; } From be85f21126276d21bcabe7b7eb07183c6bd80883 Mon Sep 17 00:00:00 2001 From: Gravita <12893402+gravit0@users.noreply.github.com> Date: Sat, 25 Feb 2023 18:43:04 +0700 Subject: [PATCH 4/5] [FIX] Save options settings after hot profile reload --- build.gradle | 6 +++--- .../gravit/launcher/client/gui/service/StateService.java | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 2adb169d..d9b3ea2e 100644 --- a/build.gradle +++ b/build.gradle @@ -57,9 +57,9 @@ repositories { } dependencies { - implementation "pro.gravit.launcher:launcher-core:5.3.2" - implementation "pro.gravit.launcher:launcher-ws-api:5.3.2" - implementation "pro.gravit.launcher:launcher-client-api:5.3.2" + implementation "pro.gravit.launcher:launcher-core:5.3.6-SNAPSHOT" + implementation "pro.gravit.launcher:launcher-ws-api:5.3.6-SNAPSHOT" + implementation "pro.gravit.launcher:launcher-client-api:5.3.6-SNAPSHOT" implementation "pro.gravit.utils.enfs:enfs:1.0.0-SNAPSHOT" implementation 'io.netty:netty-codec-http:4.1.67.Final' implementation 'com.github.oshi:oshi-core:5.8.1' diff --git a/src/main/java/pro/gravit/launcher/client/gui/service/StateService.java b/src/main/java/pro/gravit/launcher/client/gui/service/StateService.java index 81ecfa31..5e7ef1fe 100644 --- a/src/main/java/pro/gravit/launcher/client/gui/service/StateService.java +++ b/src/main/java/pro/gravit/launcher/client/gui/service/StateService.java @@ -5,6 +5,7 @@ import pro.gravit.launcher.events.request.ProfilesRequestEvent; import pro.gravit.launcher.profiles.ClientProfile; import pro.gravit.launcher.profiles.PlayerProfile; +import pro.gravit.launcher.profiles.optional.OptionalFile; import pro.gravit.launcher.profiles.optional.OptionalView; import pro.gravit.launcher.request.Request; @@ -61,9 +62,10 @@ public void setProfilesResult(ProfilesRequestEvent rawProfilesResult) { this.profiles = rawProfilesResult.profiles; this.profiles.sort(ClientProfile::compareTo); if (this.optionalViewMap == null) this.optionalViewMap = new HashMap<>(); - else this.optionalViewMap.clear(); for (ClientProfile profile : profiles) { - this.optionalViewMap.put(profile, new OptionalView(profile)); + OptionalView oldView = this.optionalViewMap.get(profile); + OptionalView newView = oldView != null ? new OptionalView(profile, oldView) : new OptionalView(profile); + this.optionalViewMap.put(profile, newView); } } From 2e5313bf2cafac1c4563c1c6612dde186549b46e Mon Sep 17 00:00:00 2001 From: Gravita <12893402+gravit0@users.noreply.github.com> Date: Fri, 3 Mar 2023 18:05:47 +0700 Subject: [PATCH 5/5] [ANY] 2.1.4 release --- build.gradle | 6 +++--- .../java/pro/gravit/launcher/client/JavaRuntimeModule.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index d9b3ea2e..0956acda 100644 --- a/build.gradle +++ b/build.gradle @@ -57,9 +57,9 @@ repositories { } dependencies { - implementation "pro.gravit.launcher:launcher-core:5.3.6-SNAPSHOT" - implementation "pro.gravit.launcher:launcher-ws-api:5.3.6-SNAPSHOT" - implementation "pro.gravit.launcher:launcher-client-api:5.3.6-SNAPSHOT" + implementation "pro.gravit.launcher:launcher-core:5.3.6" + implementation "pro.gravit.launcher:launcher-ws-api:5.3.6" + implementation "pro.gravit.launcher:launcher-client-api:5.3.6" implementation "pro.gravit.utils.enfs:enfs:1.0.0-SNAPSHOT" implementation 'io.netty:netty-codec-http:4.1.67.Final' implementation 'com.github.oshi:oshi-core:5.8.1' diff --git a/src/main/java/pro/gravit/launcher/client/JavaRuntimeModule.java b/src/main/java/pro/gravit/launcher/client/JavaRuntimeModule.java index bf3de668..cbf53c6b 100644 --- a/src/main/java/pro/gravit/launcher/client/JavaRuntimeModule.java +++ b/src/main/java/pro/gravit/launcher/client/JavaRuntimeModule.java @@ -30,7 +30,7 @@ public class JavaRuntimeModule extends LauncherModule { private RuntimeProvider provider; public JavaRuntimeModule() { - super(new LauncherModuleInfo("StdJavaRuntime", new Version(2, 1, 3, 1, Version.Type.STABLE), + super(new LauncherModuleInfo("StdJavaRuntime", new Version(2, 1, 4, 1, Version.Type.STABLE), 0, new String[]{}, new String[]{"runtime"})); }