mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-07-07 00:09:46 +03:00
Compare commits
8 commits
a959414c64
...
183d0fc9df
Author | SHA1 | Date | |
---|---|---|---|
|
183d0fc9df | ||
|
e1ee1099cc | ||
|
b0e840a040 | ||
|
0de8ff6e14 | ||
|
b9c6472e2a | ||
|
230fd22f99 | ||
|
d2a8bc2c35 | ||
|
ab1fa64f7a |
5 changed files with 51 additions and 20 deletions
|
@ -60,12 +60,7 @@ public UncompletedProfile create(String name, String description, CompletedProfi
|
||||||
.setAssetDir("assets")
|
.setAssetDir("assets")
|
||||||
.createClientProfile(), null, getUpdatesDir("assets"));
|
.createClientProfile(), null, getUpdatesDir("assets"));
|
||||||
}
|
}
|
||||||
profilesMap.put(profile.getUuid(), profile);
|
pushProfileAndSave(profile);
|
||||||
try(Writer writer = IOHelper.newWriter(profile.getConfigPath())) {
|
|
||||||
Launcher.gsonManager.configGson.toJson(profile.profile, writer);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,10 +98,19 @@ public CompletedProfile pushUpdate(UncompletedProfile profile, String tag, Clien
|
||||||
execute(localProfile.clientDir, clientDir, clientActions);
|
execute(localProfile.clientDir, clientDir, clientActions);
|
||||||
localProfile.clientDir = new HashedDir(clientDir, null, true, true);
|
localProfile.clientDir = new HashedDir(clientDir, null, true, true);
|
||||||
}
|
}
|
||||||
profilesMap.put(localProfile.getUuid(), localProfile);
|
pushProfileAndSave(localProfile);
|
||||||
return localProfile;
|
return localProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void pushProfileAndSave(LocalProfile localProfile) {
|
||||||
|
profilesMap.put(localProfile.getUuid(), localProfile);
|
||||||
|
try(Writer writer = IOHelper.newWriter(localProfile.getConfigPath())) {
|
||||||
|
Launcher.gsonManager.configGson.toJson(localProfile.profile, writer);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void download(CompletedProfile profile, Map<String, Path> files, boolean assets) throws IOException {
|
public void download(CompletedProfile profile, Map<String, Path> files, boolean assets) throws IOException {
|
||||||
Path sourceDir = Path.of(updatesDir).resolve(assets ? profile.getProfile().getAssetDir() : profile.getProfile().getDir());
|
Path sourceDir = Path.of(updatesDir).resolve(assets ? profile.getProfile().getAssetDir() : profile.getProfile().getDir());
|
||||||
|
@ -320,7 +324,7 @@ public void invoke(String... args) throws Exception {
|
||||||
try {
|
try {
|
||||||
if (!IOHelper.isDir(Path.of(updatesDir)))
|
if (!IOHelper.isDir(Path.of(updatesDir)))
|
||||||
Files.createDirectory(Path.of(updatesDir));
|
Files.createDirectory(Path.of(updatesDir));
|
||||||
readUpdatesDir();
|
sync(null);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("Updates not synced", e);
|
logger.error("Updates not synced", e);
|
||||||
}
|
}
|
||||||
|
@ -339,16 +343,16 @@ public void invoke(String... args) throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LocalProfile implements CompletedProfile {
|
public class LocalProfile implements CompletedProfile {
|
||||||
private ClientProfile profile;
|
private volatile ClientProfile profile;
|
||||||
private HashedDir clientDir;
|
private volatile HashedDir clientDir;
|
||||||
private HashedDir assetDir;
|
private volatile HashedDir assetDir;
|
||||||
private Path configPath;
|
private Path configPath;
|
||||||
|
|
||||||
public LocalProfile(ClientProfile profile, HashedDir clientDir, HashedDir assetDir) {
|
public LocalProfile(ClientProfile profile, HashedDir clientDir, HashedDir assetDir) {
|
||||||
this.profile = profile;
|
this.profile = profile;
|
||||||
this.clientDir = clientDir;
|
this.clientDir = clientDir;
|
||||||
this.assetDir = assetDir;
|
this.assetDir = assetDir;
|
||||||
this.configPath = Path.of(profilesDir).resolve(profile.getDir());
|
this.configPath = Path.of(profilesDir).resolve(profile.getDir().concat(".json"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalProfile(ClientProfile profile, HashedDir clientDir, HashedDir assetDir, Path configPath) {
|
public LocalProfile(ClientProfile profile, HashedDir clientDir, HashedDir assetDir, Path configPath) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ public class AssetsDirHelper {
|
||||||
|
|
||||||
public static List<Downloader.SizedFile> makeToDownloadFiles(AssetInfo assetInfo, HashedDir updatesDir) {
|
public static List<Downloader.SizedFile> makeToDownloadFiles(AssetInfo assetInfo, HashedDir updatesDir) {
|
||||||
List<Downloader.SizedFile> toDownload = new ArrayList<>(128);
|
List<Downloader.SizedFile> toDownload = new ArrayList<>(128);
|
||||||
for (var e : assetInfo.assets.entrySet()) {
|
for (var e : assetInfo.assets.getAsJsonObject("objects").entrySet()) {
|
||||||
var value = e.getValue().getAsJsonObject();
|
var value = e.getValue().getAsJsonObject();
|
||||||
var hash = value.get("hash").getAsString();
|
var hash = value.get("hash").getAsString();
|
||||||
hash = hash.substring(0, 2) + "/" + hash;
|
hash = hash.substring(0, 2) + "/" + hash;
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class LauncherBackendImpl implements LauncherBackendAPI, TextureUploadExtension {
|
public class LauncherBackendImpl implements LauncherBackendAPI, TextureUploadExtension {
|
||||||
private final ClientDownloadImpl clientDownloadImpl = new ClientDownloadImpl(this);
|
private final ClientDownloadImpl clientDownloadImpl = new ClientDownloadImpl(this);
|
||||||
|
@ -53,7 +54,7 @@ public class LauncherBackendImpl implements LauncherBackendAPI, TextureUploadExt
|
||||||
// Hardware
|
// Hardware
|
||||||
private volatile ECKeyHolder ecKeyHolder;
|
private volatile ECKeyHolder ecKeyHolder;
|
||||||
// Data
|
// Data
|
||||||
private volatile List<ProfileFeatureAPI.ClientProfile> profiles;
|
private volatile Map<UUID, ProfileFeatureAPI.ClientProfile> profiles;
|
||||||
private volatile UserPermissions permissions;
|
private volatile UserPermissions permissions;
|
||||||
private volatile SelfUser selfUser;
|
private volatile SelfUser selfUser;
|
||||||
private volatile List<Java> availableJavas;
|
private volatile List<Java> availableJavas;
|
||||||
|
@ -184,12 +185,23 @@ public CompletableFuture<SelfUser> authorize(String login, AuthMethodPassword pa
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<List<ProfileFeatureAPI.ClientProfile>> fetchProfiles() {
|
public CompletableFuture<List<ProfileFeatureAPI.ClientProfile>> fetchProfiles() {
|
||||||
return LauncherAPIHolder.profile().getProfiles().thenApply((profiles) -> {
|
return LauncherAPIHolder.profile().getProfiles().thenApply((profiles) -> {
|
||||||
this.profiles = profiles;
|
onProfiles(profiles);
|
||||||
callback.onProfiles(profiles);
|
callback.onProfiles(profiles);
|
||||||
return profiles;
|
return profiles;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onProfiles(List<ProfileFeatureAPI.ClientProfile> 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
|
@Override
|
||||||
public ClientProfileSettings makeClientProfileSettings(ProfileFeatureAPI.ClientProfile profile) {
|
public ClientProfileSettings makeClientProfileSettings(ProfileFeatureAPI.ClientProfile profile) {
|
||||||
var settings = backendSettings.settings.get(profile.getUUID());
|
var settings = backendSettings.settings.get(profile.getUUID());
|
||||||
|
|
|
@ -316,7 +316,7 @@ public boolean hasFlag(CompatibilityFlags flag) {
|
||||||
|
|
||||||
public void verify() {
|
public void verify() {
|
||||||
// Version
|
// Version
|
||||||
getVersion();
|
getMinecraftVersion();
|
||||||
IOHelper.verifyFileName(getAssetIndex());
|
IOHelper.verifyFileName(getAssetIndex());
|
||||||
|
|
||||||
// Client
|
// Client
|
||||||
|
|
|
@ -5,7 +5,12 @@
|
||||||
import pro.gravit.launcher.base.api.AuthService;
|
import pro.gravit.launcher.base.api.AuthService;
|
||||||
import pro.gravit.launcher.base.api.ClientService;
|
import pro.gravit.launcher.base.api.ClientService;
|
||||||
import pro.gravit.launcher.base.api.KeyService;
|
import pro.gravit.launcher.base.api.KeyService;
|
||||||
|
import pro.gravit.launcher.base.request.*;
|
||||||
import pro.gravit.launcher.client.events.*;
|
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.FileNameMatcher;
|
||||||
import pro.gravit.launcher.core.hasher.HashedDir;
|
import pro.gravit.launcher.core.hasher.HashedDir;
|
||||||
import pro.gravit.launcher.core.hasher.HashedEntry;
|
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.OptionalAction;
|
||||||
import pro.gravit.launcher.base.profiles.optional.actions.OptionalActionClassPath;
|
import pro.gravit.launcher.base.profiles.optional.actions.OptionalActionClassPath;
|
||||||
import pro.gravit.launcher.base.profiles.optional.actions.OptionalActionClientArgs;
|
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.base.request.websockets.StdWebSocketService;
|
||||||
import pro.gravit.launcher.core.serialize.HInput;
|
import pro.gravit.launcher.core.serialize.HInput;
|
||||||
import pro.gravit.launcher.client.utils.DirWatcher;
|
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);
|
LogHelper.debug("Natives dir %s", params.nativesDir);
|
||||||
ClientProfile.ClassLoaderConfig classLoaderConfig = profile.getClassLoaderConfig();
|
ClientProfile.ClassLoaderConfig classLoaderConfig = profile.getClassLoaderConfig();
|
||||||
LaunchOptions options = new LaunchOptions();
|
LaunchOptions options = new LaunchOptions();
|
||||||
|
@ -151,7 +166,7 @@ private static void realMain(String[] args) throws Throwable {
|
||||||
}
|
}
|
||||||
Set<Path> ignoredPath = new HashSet<>();
|
Set<Path> ignoredPath = new HashSet<>();
|
||||||
if(options.moduleConf != null && options.moduleConf.modulePath != null) {
|
if(options.moduleConf != null && options.moduleConf.modulePath != null) {
|
||||||
List<Path> resolvedModulePath = resolveClassPath(ignoredPath, clientDir, null, params.profile).toList();
|
List<Path> resolvedModulePath = resolveClassPathStream(ignoredPath, clientDir, options.moduleConf.modulePath).toList();
|
||||||
}
|
}
|
||||||
List<Path> classpath = resolveClassPath(ignoredPath, clientDir, params.actions, params.profile)
|
List<Path> classpath = resolveClassPath(ignoredPath, clientDir, params.actions, params.profile)
|
||||||
.collect(Collectors.toCollection(ArrayList::new));
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
|
|
Loading…
Reference in a new issue