mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
[FEATURE][FIX] Нормальное API доступа к параметрам при запуске клиента
This commit is contained in:
parent
8f42175ad4
commit
05b214c11a
4 changed files with 43 additions and 6 deletions
|
@ -36,6 +36,7 @@
|
|||
import pro.gravit.launcher.api.ClientService;
|
||||
import pro.gravit.launcher.client.events.ClientLaunchPhase;
|
||||
import pro.gravit.launcher.client.events.ClientLauncherInitPhase;
|
||||
import pro.gravit.launcher.client.events.ClientLauncherPostInitPhase;
|
||||
import pro.gravit.launcher.guard.LauncherGuardManager;
|
||||
import pro.gravit.launcher.gui.JSRuntimeProvider;
|
||||
import pro.gravit.launcher.hasher.FileNameMatcher;
|
||||
|
@ -437,6 +438,21 @@ public static Process launch(
|
|||
clientStarted = false;
|
||||
return process;
|
||||
}
|
||||
public static class ClientLaunchContext
|
||||
{
|
||||
public final Params params;
|
||||
public final ClientProfile profile;
|
||||
public final HashedDir assetHDir, clientHDir;
|
||||
public DirWatcher assetWatcher, clientWatcher;
|
||||
|
||||
|
||||
public ClientLaunchContext(Params params, ClientProfile profile, HashedDir assetHDir, HashedDir clientHDir) {
|
||||
this.params = params;
|
||||
this.profile = profile;
|
||||
this.assetHDir = assetHDir;
|
||||
this.clientHDir = clientHDir;
|
||||
}
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public static void main(String... args) throws Throwable {
|
||||
|
@ -477,11 +493,12 @@ public static void main(String... args) throws Throwable {
|
|||
System.exit(-98);
|
||||
return;
|
||||
}
|
||||
ClientLaunchContext context = new ClientLaunchContext(params, profile, assetHDir, clientHDir);
|
||||
Launcher.profile = profile;
|
||||
playerProfile = params.pp;
|
||||
Request.setSession(params.session);
|
||||
checkJVMBitsAndVersion();
|
||||
LauncherEngine.modulesManager.invokeEvent(new ClientLauncherInitPhase());
|
||||
LauncherEngine.modulesManager.invokeEvent(new ClientLauncherInitPhase(context));
|
||||
// Verify ClientLauncher sign and classpath
|
||||
LogHelper.debug("Verifying ClientLauncher sign and classpath");
|
||||
LinkedList<Path> classPath = resolveClassPathList(params.clientDir, profile.getClassPath());
|
||||
|
@ -537,14 +554,16 @@ public static void main(String... args) throws Throwable {
|
|||
// if (params.updateOptional.contains(s)) s.mark = true;
|
||||
// else hdir.removeR(s.file);
|
||||
//}
|
||||
context.assetWatcher = assetWatcher;
|
||||
context.clientWatcher = clientWatcher;
|
||||
Launcher.profile.pushOptionalFile(clientHDir, false);
|
||||
LauncherEngine.modulesManager.invokeEvent(new PostInitPhase());
|
||||
LauncherEngine.modulesManager.invokeEvent(new ClientLauncherPostInitPhase(context));
|
||||
// Start WatchService, and only then client
|
||||
CommonHelper.newThread("Asset Directory Watcher", true, assetWatcher).start();
|
||||
CommonHelper.newThread("Client Directory Watcher", true, clientWatcher).start();
|
||||
verifyHDir(params.assetDir, assetHDir, assetMatcher, digest);
|
||||
verifyHDir(params.clientDir, clientHDir, clientMatcher, digest);
|
||||
LauncherEngine.modulesManager.invokeEvent(new ClientLaunchPhase(params));
|
||||
LauncherEngine.modulesManager.invokeEvent(new ClientLaunchPhase(context));
|
||||
launch(profile, params);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
import pro.gravit.launcher.modules.LauncherModule;
|
||||
|
||||
public class ClientLaunchPhase extends LauncherModule.Event {
|
||||
public final ClientLauncher.Params params;
|
||||
public final ClientLauncher.ClientLaunchContext context;
|
||||
|
||||
public ClientLaunchPhase(ClientLauncher.Params params) {
|
||||
this.params = params;
|
||||
public ClientLaunchPhase(ClientLauncher.ClientLaunchContext context) {
|
||||
this.context = context;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
package pro.gravit.launcher.client.events;
|
||||
|
||||
import pro.gravit.launcher.client.ClientLauncher;
|
||||
import pro.gravit.launcher.modules.events.InitPhase;
|
||||
|
||||
public class ClientLauncherInitPhase extends InitPhase {
|
||||
public final ClientLauncher.ClientLaunchContext context;
|
||||
|
||||
public ClientLauncherInitPhase(ClientLauncher.ClientLaunchContext context) {
|
||||
this.context = context;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package pro.gravit.launcher.client.events;
|
||||
|
||||
import pro.gravit.launcher.client.ClientLauncher;
|
||||
import pro.gravit.launcher.modules.events.PostInitPhase;
|
||||
|
||||
public class ClientLauncherPostInitPhase extends PostInitPhase {
|
||||
public final ClientLauncher.ClientLaunchContext context;
|
||||
|
||||
public ClientLauncherPostInitPhase(ClientLauncher.ClientLaunchContext context) {
|
||||
this.context = context;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue