Skip to content

Commit

Permalink
Merge branch 'release/4.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
gravit0 committed May 31, 2024
2 parents f490252 + 998f8ac commit 39e38fb
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 23 deletions.
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ javafx {
sourceCompatibility = '17'
targetCompatibility = '17'
group 'pro.gravit.launcher'
version '4.0.0'
version '4.0.2'
def mainClassName = "pro.gravit.launcher.gui.JavaRuntimeModule"

task sourcesJar(type: Jar) {
Expand Down Expand Up @@ -58,11 +58,11 @@ repositories {
}

dependencies {
implementation "pro.gravit.launcher:launcher-core:5.6.1"
implementation "pro.gravit.launcher:launcher-ws-api:5.6.1"
implementation "pro.gravit.launcher:launcher-client-api:5.6.1"
implementation "pro.gravit.launcher:launcher-client-start-api:5.6.1"
implementation "pro.gravit.launcher:launcher-client-starter-api:5.6.1"
implementation "pro.gravit.launcher:launcher-core:5.6.2"
implementation "pro.gravit.launcher:launcher-ws-api:5.6.2"
implementation "pro.gravit.launcher:launcher-client-api:5.6.2"
implementation "pro.gravit.launcher:launcher-client-start-api:5.6.2"
implementation "pro.gravit.launcher:launcher-client-starter-api:5.6.2"
implementation "pro.gravit.utils.enfs:enfs:2.0.1-SNAPSHOT"
implementation 'io.netty:netty-codec-http:4.1.67.Final'
implementation 'com.github.oshi:oshi-core:5.8.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class JavaRuntimeModule extends LauncherModule {

public JavaRuntimeModule() {
super(new LauncherModuleInfo("StdJavaRuntime",
new Version(4, 0, 1, 1, Version.Type.STABLE),
new Version(4, 0, 2, 1, Version.Type.STABLE),
0, new String[]{}, new String[]{"runtime"}));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package pro.gravit.launcher.gui.config;
import pro.gravit.launcher.gui.JavaFXApplication;
import pro.gravit.launcher.gui.service.JavaService;
import pro.gravit.launcher.gui.utils.SystemTheme;
import pro.gravit.launcher.runtime.client.DirBridge;
Expand Down Expand Up @@ -108,6 +107,10 @@ public static class ProfileSettings {
public String javaPath;
@LauncherNetworkAPI
public boolean waylandSupport;
@LauncherNetworkAPI
public boolean debugSkipUpdate;
@LauncherNetworkAPI
public boolean debugSkipFileMonitor;

public static ProfileSettings getDefault(JavaService javaService, ClientProfile profile) {
ProfileSettings settings = new ProfileSettings();
Expand All @@ -119,6 +122,8 @@ public static ProfileSettings getDefault(JavaService javaService, ClientProfile
if (version != null) {
settings.javaPath = version.jvmDir.toString();
}
settings.debugSkipUpdate = false;
settings.debugSkipFileMonitor = false;
return settings;
}

Expand All @@ -135,6 +140,8 @@ public static class ProfileSettingsView {
public boolean autoEnter;
public String javaPath;
public boolean waylandSupport;
public boolean debugSkipUpdate;
public boolean debugSkipFileMonitor;

public ProfileSettingsView(ProfileSettings settings) {
ram = settings.ram;
Expand All @@ -143,6 +150,8 @@ public ProfileSettingsView(ProfileSettings settings) {
autoEnter = settings.autoEnter;
javaPath = settings.javaPath;
waylandSupport = settings.waylandSupport;
debugSkipUpdate = settings.debugSkipUpdate;
debugSkipFileMonitor = settings.debugSkipFileMonitor;
this.settings = settings;
}

Expand All @@ -153,6 +162,8 @@ public void apply() {
settings.fullScreen = fullScreen;
settings.javaPath = javaPath;
settings.waylandSupport = waylandSupport;
settings.debugSkipUpdate = debugSkipUpdate;
settings.debugSkipFileMonitor = debugSkipFileMonitor;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ public void reset() {
if(JVMHelper.OS_TYPE == JVMHelper.OS.LINUX) {
add("WaylandSupport", profileSettings.waylandSupport, (value) -> profileSettings.waylandSupport = value);
}
if(application.authService.checkDebugPermission("skipupdate")) {
add("DebugSkipUpdate", profileSettings.debugSkipUpdate, (value) -> profileSettings.debugSkipUpdate = value);
}
if(application.authService.checkDebugPermission("skipfilemonitor")) {
add("DebugSkipFileMonitor", profileSettings.debugSkipFileMonitor, (value) -> profileSettings.debugSkipFileMonitor = value);
}
userBlock.reset();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ private void onUpdateStatus(DownloadStatus newStatus) {
}

public void sendUpdateAssetRequest(String dirName, Path dir, FileNameMatcher matcher, boolean digest,
String assetIndex, Consumer<HashedDir> onSuccess) {
downloader.sendUpdateAssetRequest(dirName, dir, matcher, digest, assetIndex, onSuccess);
String assetIndex, boolean test, Consumer<HashedDir> onSuccess) {
downloader.sendUpdateAssetRequest(dirName, dir, matcher, digest, assetIndex, test, onSuccess);
}

public void sendUpdateRequest(String dirName, Path dir, FileNameMatcher matcher, boolean digest, OptionalView view,
boolean optionalsEnabled, Consumer<HashedDir> onSuccess) {
downloader.sendUpdateRequest(dirName, dir, matcher, digest, view, optionalsEnabled, onSuccess);
boolean optionalsEnabled, boolean test, Consumer<HashedDir> onSuccess) {
downloader.sendUpdateRequest(dirName, dir, matcher, digest, view, optionalsEnabled, test, onSuccess);
}

public void addLog(String string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public VisualDownloader(JavaFXApplication application, ProgressBar progressBar,
}

public void sendUpdateAssetRequest(String dirName, Path dir, FileNameMatcher matcher, boolean digest,
String assetIndex, Consumer<HashedDir> onSuccess) {
if (application.offlineService.isOfflineMode()) {
String assetIndex, boolean test, Consumer<HashedDir> onSuccess) {
if (test) {
addLog.accept("Hashing %s".formatted(dirName));
updateStatus.accept(UpdateScene.DownloadStatus.HASHING);
application.workers.submit(() -> {
Expand Down Expand Up @@ -102,8 +102,8 @@ public void sendUpdateAssetRequest(String dirName, Path dir, FileNameMatcher mat
}

public void sendUpdateRequest(String dirName, Path dir, FileNameMatcher matcher, boolean digest, OptionalView view,
boolean optionalsEnabled, Consumer<HashedDir> onSuccess) {
if (application.offlineService.isOfflineMode()) {
boolean optionalsEnabled, boolean test, Consumer<HashedDir> onSuccess) {
if (test) {
addLog.accept("Hashing %s".formatted(dirName));
updateStatus.accept(UpdateScene.DownloadStatus.HASHING);
application.workers.submit(() -> {
Expand Down
28 changes: 21 additions & 7 deletions src/main/java/pro/gravit/launcher/gui/service/LaunchService.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package pro.gravit.launcher.gui.service;

import pro.gravit.launcher.base.Launcher;
import pro.gravit.launcher.base.profiles.ClientProfileBuilder;
import pro.gravit.launcher.gui.JavaFXApplication;
import pro.gravit.launcher.gui.config.RuntimeSettings;
import pro.gravit.launcher.gui.impl.AbstractStage;
Expand All @@ -20,6 +21,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
Expand All @@ -32,15 +34,20 @@ public LaunchService(JavaFXApplication application) {
this.application = application;
}

private void downloadClients(CompletableFuture<ClientInstance> future, ClientProfile profile, JavaHelper.JavaVersion javaVersion, HashedDir jvmHDir) {
public boolean isTestUpdate(ClientProfile profile, RuntimeSettings.ProfileSettings settings) {
return application.offlineService.isOfflineMode() || (application.authService.checkDebugPermission("skipupdate") && settings.debugSkipUpdate);
}

private void downloadClients(CompletableFuture<ClientInstance> future, ClientProfile profile, RuntimeSettings.ProfileSettings settings, JavaHelper.JavaVersion javaVersion, HashedDir jvmHDir) {
Path target = DirBridge.dirUpdates.resolve(profile.getAssetDir());
LogHelper.info("Start update to %s", target.toString());
boolean testUpdate = isTestUpdate(profile, settings);
Consumer<HashedDir> next = (assetHDir) -> {
Path targetClient = DirBridge.dirUpdates.resolve(profile.getDir());
LogHelper.info("Start update to %s", targetClient.toString());
application.gui.updateScene.sendUpdateRequest(profile.getDir(), targetClient,
profile.getClientUpdateMatcher(), true,
application.profilesService.getOptionalView(), true,
application.profilesService.getOptionalView(), true, testUpdate,
(clientHDir) -> {
LogHelper.info("Success update");
try {
Expand All @@ -56,11 +63,11 @@ private void downloadClients(CompletableFuture<ClientInstance> future, ClientPro
};
if (profile.getVersion().compareTo(ClientProfileVersions.MINECRAFT_1_6_4) <= 0) {
application.gui.updateScene.sendUpdateRequest(profile.getAssetDir(), target,
profile.getAssetUpdateMatcher(), true, null, false, next);
profile.getAssetUpdateMatcher(), true, null, false, testUpdate, next);
} else {
application.gui.updateScene.sendUpdateAssetRequest(profile.getAssetDir(), target,
profile.getAssetUpdateMatcher(), true,
profile.getAssetIndex(), next);
profile.getAssetIndex(), testUpdate, next);
}
}

Expand All @@ -73,6 +80,13 @@ private ClientInstance doLaunchClient(Path assetDir, HashedDir assetHDir, Path c
if (javaVersion == null) {
javaVersion = JavaHelper.JavaVersion.getCurrentJavaVersion();
}
if(application.authService.checkDebugPermission("skipfilemonitor") && profileSettings.debugSkipFileMonitor) {
var builder = new ClientProfileBuilder(profile);
builder.setUpdate(new ArrayList<>());
builder.setUpdateVerify(new ArrayList<>());
builder.setUpdateExclusions(new ArrayList<>());
profile = builder.createClientProfile();
}
ClientLauncherProcess clientLauncherProcess =
new ClientLauncherProcess(clientDir, assetDir, javaVersion, clientDir.resolve("resourcepacks"), profile,
application.authService.getPlayerProfile(), view,
Expand Down Expand Up @@ -162,7 +176,7 @@ private CompletableFuture<ClientInstance> launchClient(AbstractStage stage) {
}
application.gui.updateScene.
sendUpdateRequest(jvmDirName, javaVersion.jvmDir, null, true,
application.profilesService.getOptionalView(), false,
application.profilesService.getOptionalView(), false, isTestUpdate(profile, profileSettings),
(jvmHDir) -> {
if (JVMHelper.OS_TYPE == JVMHelper.OS.LINUX
|| JVMHelper.OS_TYPE == JVMHelper.OS.MACOSX) {
Expand All @@ -176,7 +190,7 @@ private CompletableFuture<ClientInstance> launchClient(AbstractStage stage) {
}
}
}
downloadClients(future, profile, finalJavaVersion, jvmHDir);
downloadClients(future, profile, profileSettings, finalJavaVersion, jvmHDir);
});
} else {
try {
Expand All @@ -185,7 +199,7 @@ private CompletableFuture<ClientInstance> launchClient(AbstractStage stage) {
} catch (Exception e) {
future.completeExceptionally(e);
}
downloadClients(future, profile, javaVersion, null);
downloadClients(future, profile, profileSettings, javaVersion, null);
}
}), future::completeExceptionally, null);
return future;
Expand Down

0 comments on commit 39e38fb

Please sign in to comment.