Compare commits

..

8 commits

Author SHA1 Message Date
Gravita
183d0fc9df Merge hotfix/5.6.16 2025-06-21 20:02:17 +07:00
Gravita
e1ee1099cc Merge branch 'hotfix/5.6.16' 2025-06-21 20:00:49 +07:00
Gravita
b0e840a040 [FIX] ModuleConf resolve mudule path, not class path 2025-06-21 19:59:11 +07:00
Gravita
0de8ff6e14 [FIX] Some bug fixes 2025-06-21 18:37:28 +07:00
Gravita
b9c6472e2a [FIX] Save profile after create 2025-06-21 17:58:57 +07:00
Gravita
230fd22f99 [FIX] Add .json ext to profile files 2025-06-21 17:52:31 +07:00
Gravita
d2a8bc2c35 [FIX] Fix download assets 2025-06-21 17:47:44 +07:00
Gravita
ab1fa64f7a [FIX] Fix sync command 2025-06-21 17:00:36 +07:00
5 changed files with 51 additions and 20 deletions

View file

@ -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) {

View file

@ -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;

View file

@ -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());

View file

@ -316,7 +316,7 @@ public boolean hasFlag(CompatibilityFlags flag) {
public void verify() {
// Version
getVersion();
getMinecraftVersion();
IOHelper.verifyFileName(getAssetIndex());
// Client

View file

@ -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));