mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-07-07 08:19:45 +03:00
Compare commits
No commits in common. "183d0fc9dfab8e4fdb54531dc2295396344f784f" and "a959414c640e7a8ddfdb3ba5d422498d3beac151" have entirely different histories.
183d0fc9df
...
a959414c64
5 changed files with 20 additions and 51 deletions
|
@ -60,7 +60,12 @@ public UncompletedProfile create(String name, String description, CompletedProfi
|
||||||
.setAssetDir("assets")
|
.setAssetDir("assets")
|
||||||
.createClientProfile(), null, getUpdatesDir("assets"));
|
.createClientProfile(), null, getUpdatesDir("assets"));
|
||||||
}
|
}
|
||||||
pushProfileAndSave(profile);
|
profilesMap.put(profile.getUuid(), 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,17 +103,8 @@ 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);
|
||||||
}
|
}
|
||||||
pushProfileAndSave(localProfile);
|
|
||||||
return localProfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void pushProfileAndSave(LocalProfile localProfile) {
|
|
||||||
profilesMap.put(localProfile.getUuid(), localProfile);
|
profilesMap.put(localProfile.getUuid(), localProfile);
|
||||||
try(Writer writer = IOHelper.newWriter(localProfile.getConfigPath())) {
|
return localProfile;
|
||||||
Launcher.gsonManager.configGson.toJson(localProfile.profile, writer);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -324,7 +320,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));
|
||||||
sync(null);
|
readUpdatesDir();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("Updates not synced", e);
|
logger.error("Updates not synced", e);
|
||||||
}
|
}
|
||||||
|
@ -343,16 +339,16 @@ public void invoke(String... args) throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LocalProfile implements CompletedProfile {
|
public class LocalProfile implements CompletedProfile {
|
||||||
private volatile ClientProfile profile;
|
private ClientProfile profile;
|
||||||
private volatile HashedDir clientDir;
|
private HashedDir clientDir;
|
||||||
private volatile HashedDir assetDir;
|
private 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().concat(".json"));
|
this.configPath = Path.of(profilesDir).resolve(profile.getDir());
|
||||||
}
|
}
|
||||||
|
|
||||||
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.getAsJsonObject("objects").entrySet()) {
|
for (var e : assetInfo.assets.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,7 +40,6 @@
|
||||||
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);
|
||||||
|
@ -54,7 +53,7 @@ public class LauncherBackendImpl implements LauncherBackendAPI, TextureUploadExt
|
||||||
// Hardware
|
// Hardware
|
||||||
private volatile ECKeyHolder ecKeyHolder;
|
private volatile ECKeyHolder ecKeyHolder;
|
||||||
// Data
|
// Data
|
||||||
private volatile Map<UUID, ProfileFeatureAPI.ClientProfile> profiles;
|
private volatile List<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;
|
||||||
|
@ -185,23 +184,12 @@ 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) -> {
|
||||||
onProfiles(profiles);
|
this.profiles = 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
|
||||||
getMinecraftVersion();
|
getVersion();
|
||||||
IOHelper.verifyFileName(getAssetIndex());
|
IOHelper.verifyFileName(getAssetIndex());
|
||||||
|
|
||||||
// Client
|
// Client
|
||||||
|
|
|
@ -5,12 +5,7 @@
|
||||||
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;
|
||||||
|
@ -20,6 +15,9 @@
|
||||||
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;
|
||||||
|
@ -140,19 +138,6 @@ 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();
|
||||||
|
@ -166,7 +151,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 = resolveClassPathStream(ignoredPath, clientDir, options.moduleConf.modulePath).toList();
|
List<Path> resolvedModulePath = resolveClassPath(ignoredPath, clientDir, null, params.profile).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