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