diff --git a/build.gradle b/build.gradle index 2adb169d..0956acda 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" + 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"})); } 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..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 @@ -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,20 @@ 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.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; + } + public boolean isIncompatibleJava(JavaHelper.JavaVersion version, ClientProfile profile) { return version.version > profile.getMaxJavaVersion() || version.version < profile.getMinJavaVersion() || (!version.enabledJavaFX && profile.getRuntimeInClientConfig() != ClientProfile.RuntimeInClientConfig.NONE) 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); } }