mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
[FEATURE] Support "Runtime in Client"
This commit is contained in:
parent
37ec6b525c
commit
a34b2c206b
4 changed files with 27 additions and 9 deletions
|
@ -45,9 +45,11 @@ public class LauncherEngine {
|
|||
public RuntimeProvider runtimeProvider;
|
||||
public ECPublicKey publicKey;
|
||||
public ECPrivateKey privateKey;
|
||||
public final boolean clientInstance;
|
||||
|
||||
private LauncherEngine() {
|
||||
private LauncherEngine(boolean clientInstance) {
|
||||
|
||||
this.clientInstance = clientInstance;
|
||||
}
|
||||
|
||||
//JVMHelper.getCertificates
|
||||
|
@ -103,7 +105,7 @@ public static void main(String... args) throws Throwable {
|
|||
Launcher.getConfig(); // init config
|
||||
long startTime = System.currentTimeMillis();
|
||||
try {
|
||||
new LauncherEngine().start(args);
|
||||
new LauncherEngine(false).start(args);
|
||||
} catch (Exception e) {
|
||||
LogHelper.error(e);
|
||||
return;
|
||||
|
@ -139,11 +141,11 @@ public static LauncherGuardInterface tryGetStdGuard() {
|
|||
}
|
||||
|
||||
public static LauncherEngine clientInstance() {
|
||||
return new LauncherEngine();
|
||||
return new LauncherEngine(true);
|
||||
}
|
||||
|
||||
public static LauncherEngine newInstance() {
|
||||
return new LauncherEngine();
|
||||
public static LauncherEngine newInstance(boolean clientInstance) {
|
||||
return new LauncherEngine(clientInstance);
|
||||
}
|
||||
|
||||
public void readKeys() throws IOException, InvalidKeySpecException {
|
||||
|
@ -175,7 +177,7 @@ public void start(String... args) throws Throwable {
|
|||
LauncherEngine.modulesManager.invokeEvent(event);
|
||||
runtimeProvider = event.runtimeProvider;
|
||||
if (runtimeProvider == null) runtimeProvider = new NoRuntimeProvider();
|
||||
runtimeProvider.init(false);
|
||||
runtimeProvider.init(clientInstance);
|
||||
//runtimeProvider.preLoad();
|
||||
if (Request.service == null) {
|
||||
String address = Launcher.getConfig().address;
|
||||
|
@ -205,7 +207,7 @@ public void start(String... args) throws Throwable {
|
|||
readKeys();
|
||||
LauncherEngine.modulesManager.invokeEvent(new ClientEngineInitPhase(this));
|
||||
runtimeProvider.preLoad();
|
||||
LauncherGuardManager.initGuard(false);
|
||||
LauncherGuardManager.initGuard(clientInstance);
|
||||
LogHelper.debug("Dir: %s", DirBridge.dir);
|
||||
runtimeProvider.run(args);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
import pro.gravit.launcher.hasher.HashedDir;
|
||||
import pro.gravit.launcher.hasher.HashedEntry;
|
||||
import pro.gravit.launcher.managers.ClientGsonManager;
|
||||
import pro.gravit.launcher.managers.ConsoleManager;
|
||||
import pro.gravit.launcher.modules.events.PreConfigPhase;
|
||||
import pro.gravit.launcher.patches.FMLPatcher;
|
||||
import pro.gravit.launcher.profiles.ClientProfile;
|
||||
|
@ -77,6 +78,7 @@ public static void main(String[] args) throws Throwable {
|
|||
LauncherConfig.initModules(LauncherEngine.modulesManager); //INIT
|
||||
LauncherEngine.modulesManager.initModules(null);
|
||||
initGson(LauncherEngine.modulesManager);
|
||||
ConsoleManager.initConsole();
|
||||
LauncherEngine.modulesManager.invokeEvent(new PreConfigPhase());
|
||||
engine.readKeys();
|
||||
LauncherGuardManager.initGuard(true);
|
||||
|
@ -153,7 +155,15 @@ public static void main(String[] args) throws Throwable {
|
|||
ClientService.classLoader = classLoader;
|
||||
ClientService.baseURLs = classpath.toArray(new URL[0]);
|
||||
}
|
||||
|
||||
if(params.profile.runtimeInClientConfig != ClientProfile.RuntimeInClientConfig.NONE) {
|
||||
CommonHelper.newThread("Client Launcher Thread", true, () -> {
|
||||
try {
|
||||
engine.start(args);
|
||||
} catch (Throwable throwable) {
|
||||
LogHelper.error(throwable);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
LauncherEngine.modulesManager.invokeEvent(new ClientProcessReadyEvent(engine, params));
|
||||
LogHelper.debug("Starting JVM and client WatchService");
|
||||
FileNameMatcher assetMatcher = profile.getAssetUpdateMatcher();
|
||||
|
|
|
@ -49,7 +49,7 @@ public static void main(String[] args) throws Throwable {
|
|||
ConsoleManager.initConsole();
|
||||
LauncherEngine.modulesManager.invokeEvent(new PreConfigPhase());
|
||||
LogHelper.debug("Initialization LauncherEngine");
|
||||
LauncherEngine instance = LauncherEngine.newInstance();
|
||||
LauncherEngine instance = LauncherEngine.newInstance(false);
|
||||
instance.start(args);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,8 @@ public final class ClientProfile implements Comparable<ClientProfile> {
|
|||
public ClassLoaderConfig classLoaderConfig = ClassLoaderConfig.LAUNCHER;
|
||||
@LauncherNetworkAPI
|
||||
public SignedClientConfig signedClientConfig = SignedClientConfig.NONE;
|
||||
@LauncherNetworkAPI
|
||||
public RuntimeInClientConfig runtimeInClientConfig = RuntimeInClientConfig.NONE;
|
||||
// Version
|
||||
@LauncherNetworkAPI
|
||||
private String version;
|
||||
|
@ -542,6 +544,10 @@ public enum SignedClientConfig {
|
|||
NONE, SIGNED
|
||||
}
|
||||
|
||||
public enum RuntimeInClientConfig {
|
||||
NONE, BASIC, FULL
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface pushOptionalClassPathCallback {
|
||||
void run(String[] opt) throws IOException;
|
||||
|
|
Loading…
Reference in a new issue