mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-07-06 15:59:47 +03:00
Compare commits
10 commits
0858ec25f5
...
282659a937
Author | SHA1 | Date | |
---|---|---|---|
|
282659a937 | ||
|
183d0fc9df | ||
|
e1ee1099cc | ||
|
b0e840a040 | ||
|
0de8ff6e14 | ||
|
b9c6472e2a | ||
|
230fd22f99 | ||
|
d2a8bc2c35 | ||
|
ab1fa64f7a | ||
|
0e1691ee4c |
6 changed files with 55 additions and 22 deletions
|
@ -60,12 +60,7 @@ public UncompletedProfile create(String name, String description, CompletedProfi
|
|||
.setAssetDir("assets")
|
||||
.createClientProfile(), null, getUpdatesDir("assets"));
|
||||
}
|
||||
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);
|
||||
}
|
||||
pushProfileAndSave(profile);
|
||||
return profile;
|
||||
}
|
||||
|
||||
|
@ -103,10 +98,19 @@ public CompletedProfile pushUpdate(UncompletedProfile profile, String tag, Clien
|
|||
execute(localProfile.clientDir, clientDir, clientActions);
|
||||
localProfile.clientDir = new HashedDir(clientDir, null, true, true);
|
||||
}
|
||||
profilesMap.put(localProfile.getUuid(), localProfile);
|
||||
pushProfileAndSave(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
|
||||
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());
|
||||
|
@ -320,7 +324,7 @@ public void invoke(String... args) throws Exception {
|
|||
try {
|
||||
if (!IOHelper.isDir(Path.of(updatesDir)))
|
||||
Files.createDirectory(Path.of(updatesDir));
|
||||
readUpdatesDir();
|
||||
sync(null);
|
||||
} catch (IOException e) {
|
||||
logger.error("Updates not synced", e);
|
||||
}
|
||||
|
@ -339,16 +343,16 @@ 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) {
|
||||
this.profile = profile;
|
||||
this.clientDir = clientDir;
|
||||
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) {
|
||||
|
|
|
@ -15,7 +15,7 @@ public class AssetsDirHelper {
|
|||
|
||||
public static List<Downloader.SizedFile> makeToDownloadFiles(AssetInfo assetInfo, HashedDir updatesDir) {
|
||||
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 hash = value.get("hash").getAsString();
|
||||
hash = hash.substring(0, 2) + "/" + hash;
|
||||
|
|
|
@ -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<ProfileFeatureAPI.ClientProfile> profiles;
|
||||
private volatile Map<UUID, ProfileFeatureAPI.ClientProfile> profiles;
|
||||
private volatile UserPermissions permissions;
|
||||
private volatile SelfUser selfUser;
|
||||
private volatile List<Java> availableJavas;
|
||||
|
@ -184,12 +185,23 @@ public CompletableFuture<SelfUser> authorize(String login, AuthMethodPassword pa
|
|||
@Override
|
||||
public CompletableFuture<List<ProfileFeatureAPI.ClientProfile>> fetchProfiles() {
|
||||
return LauncherAPIHolder.profile().getProfiles().thenApply((profiles) -> {
|
||||
this.profiles = profiles;
|
||||
onProfiles(profiles);
|
||||
callback.onProfiles(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
|
||||
public ClientProfileSettings makeClientProfileSettings(ProfileFeatureAPI.ClientProfile profile) {
|
||||
var settings = backendSettings.settings.get(profile.getUUID());
|
||||
|
|
|
@ -316,7 +316,7 @@ public boolean hasFlag(CompatibilityFlags flag) {
|
|||
|
||||
public void verify() {
|
||||
// Version
|
||||
getVersion();
|
||||
getMinecraftVersion();
|
||||
IOHelper.verifyFileName(getAssetIndex());
|
||||
|
||||
// Client
|
||||
|
|
|
@ -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();
|
||||
|
@ -151,7 +166,7 @@ private static void realMain(String[] args) throws Throwable {
|
|||
}
|
||||
Set<Path> ignoredPath = new HashSet<>();
|
||||
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)
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
# Modification of the launcher sashok724's v3 from Gravit [](https://travis-ci.com/GravitLauncher/Launcher)
|
||||
# Modification of the launcher sashok724's v3 from Gravit
|
||||
[](https://travis-ci.com/GravitLauncher/Launcher)
|
||||
[](https://discord.gg/b9QG4ygY75)
|
||||
|
||||
* [Discord channel](https://discord.gg/b9QG4ygY75)
|
||||
|
||||
|
|
Loading…
Reference in a new issue