From 0de8ff6e14658ba0d6f8992801b21f9b12a236a9 Mon Sep 17 00:00:00 2001 From: Gravita <12893402+gravit0@users.noreply.github.com> Date: Sat, 21 Jun 2025 18:14:56 +0700 Subject: [PATCH] [FIX] Some bug fixes --- .../auth/profiles/LocalProfilesProvider.java | 6 +++--- .../runtime/backend/LauncherBackendImpl.java | 16 ++++++++++++-- .../launcher/base/profiles/ClientProfile.java | 2 +- .../client/ClientLauncherEntryPoint.java | 21 ++++++++++++++++--- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/profiles/LocalProfilesProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/profiles/LocalProfilesProvider.java index 8044c96b..e7b7e662 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/profiles/LocalProfilesProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/profiles/LocalProfilesProvider.java @@ -343,9 +343,9 @@ public void invoke(String... args) throws Exception { } public class LocalProfile implements CompletedProfile { - private ClientProfile profile; - private HashedDir clientDir; - private HashedDir assetDir; + private volatile ClientProfile profile; + private volatile HashedDir clientDir; + private volatile HashedDir assetDir; private Path configPath; public LocalProfile(ClientProfile profile, HashedDir clientDir, HashedDir assetDir) { diff --git a/Launcher/src/main/java/pro/gravit/launcher/runtime/backend/LauncherBackendImpl.java b/Launcher/src/main/java/pro/gravit/launcher/runtime/backend/LauncherBackendImpl.java index e1a8caee..903f5175 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/runtime/backend/LauncherBackendImpl.java +++ b/Launcher/src/main/java/pro/gravit/launcher/runtime/backend/LauncherBackendImpl.java @@ -40,6 +40,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.function.Function; +import java.util.stream.Collectors; public class LauncherBackendImpl implements LauncherBackendAPI, TextureUploadExtension { private final ClientDownloadImpl clientDownloadImpl = new ClientDownloadImpl(this); @@ -53,7 +54,7 @@ public class LauncherBackendImpl implements LauncherBackendAPI, TextureUploadExt // Hardware private volatile ECKeyHolder ecKeyHolder; // Data - private volatile List profiles; + private volatile Map profiles; private volatile UserPermissions permissions; private volatile SelfUser selfUser; private volatile List availableJavas; @@ -184,12 +185,23 @@ public CompletableFuture authorize(String login, AuthMethodPassword pa @Override public CompletableFuture> fetchProfiles() { return LauncherAPIHolder.profile().getProfiles().thenApply((profiles) -> { - this.profiles = profiles; + onProfiles(profiles); callback.onProfiles(profiles); return profiles; }); } + private void onProfiles(List profiles) { + this.profiles = profiles.stream().collect(Collectors.toMap(ProfileFeatureAPI.ClientProfile::getUUID, x -> x)); + for(var e : backendSettings.settings.entrySet()) { + ClientProfile profile = (ClientProfile) this.profiles.get(e.getKey()); + if(profile == null) { + continue; + } + e.getValue().initAfterGson(profile, this); + } + } + @Override public ClientProfileSettings makeClientProfileSettings(ProfileFeatureAPI.ClientProfile profile) { var settings = backendSettings.settings.get(profile.getUUID()); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/base/profiles/ClientProfile.java b/LauncherAPI/src/main/java/pro/gravit/launcher/base/profiles/ClientProfile.java index 29a1ffd1..c5c71d6f 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/base/profiles/ClientProfile.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/base/profiles/ClientProfile.java @@ -316,7 +316,7 @@ public boolean hasFlag(CompatibilityFlags flag) { public void verify() { // Version - getVersion(); + getMinecraftVersion(); IOHelper.verifyFileName(getAssetIndex()); // Client diff --git a/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java b/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java index d38100b3..58d3dbc1 100644 --- a/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java +++ b/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java @@ -5,7 +5,12 @@ import pro.gravit.launcher.base.api.AuthService; import pro.gravit.launcher.base.api.ClientService; import pro.gravit.launcher.base.api.KeyService; +import pro.gravit.launcher.base.request.*; import pro.gravit.launcher.client.events.*; +import pro.gravit.launcher.core.api.LauncherAPI; +import pro.gravit.launcher.core.api.LauncherAPIHolder; +import pro.gravit.launcher.core.api.features.*; +import pro.gravit.launcher.core.backend.LauncherBackendAPIHolder; import pro.gravit.launcher.core.hasher.FileNameMatcher; import pro.gravit.launcher.core.hasher.HashedDir; import pro.gravit.launcher.core.hasher.HashedEntry; @@ -15,9 +20,6 @@ import pro.gravit.launcher.base.profiles.optional.actions.OptionalAction; import pro.gravit.launcher.base.profiles.optional.actions.OptionalActionClassPath; import pro.gravit.launcher.base.profiles.optional.actions.OptionalActionClientArgs; -import pro.gravit.launcher.base.request.Request; -import pro.gravit.launcher.base.request.RequestException; -import pro.gravit.launcher.base.request.RequestService; import pro.gravit.launcher.base.request.websockets.StdWebSocketService; import pro.gravit.launcher.core.serialize.HInput; import pro.gravit.launcher.client.utils.DirWatcher; @@ -138,6 +140,19 @@ private static void realMain(String[] args) throws Throwable { } }; } + // Init New API + LauncherAPIHolder.setCoreAPI(new RequestCoreFeatureAPIImpl(Request.getRequestService())); + LauncherAPIHolder.setCreateApiFactory((authId) -> { + var impl = new RequestFeatureAPIImpl(Request.getRequestService(), authId); + return new LauncherAPI(Map.of( + AuthFeatureAPI.class, impl, + UserFeatureAPI.class, impl, + ProfileFeatureAPI.class, impl, + TextureUploadFeatureAPI.class, impl, + HardwareVerificationFeatureAPI.class, impl)); + }); + LauncherAPIHolder.changeAuthId(params.authId); + // LogHelper.debug("Natives dir %s", params.nativesDir); ClientProfile.ClassLoaderConfig classLoaderConfig = profile.getClassLoaderConfig(); LaunchOptions options = new LaunchOptions();