mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FEATURE] DebugMain
This commit is contained in:
parent
1e7f5c9eb4
commit
344c61eaee
7 changed files with 117 additions and 7 deletions
|
@ -40,6 +40,7 @@ public MainBuildTask(LaunchServer srv) {
|
||||||
reader = new ClassMetadataReader();
|
reader = new ClassMetadataReader();
|
||||||
InjectClassAcceptor injectClassAcceptor = new InjectClassAcceptor(properties);
|
InjectClassAcceptor injectClassAcceptor = new InjectClassAcceptor(properties);
|
||||||
transformers.add(injectClassAcceptor);
|
transformers.add(injectClassAcceptor);
|
||||||
|
blacklist.add("pro/gravit/launcher/debug/");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -140,6 +140,10 @@ public static LauncherEngine clientInstance() {
|
||||||
return new LauncherEngine();
|
return new LauncherEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static LauncherEngine newInstance() {
|
||||||
|
return new LauncherEngine();
|
||||||
|
}
|
||||||
|
|
||||||
public void readKeys() throws IOException, InvalidKeySpecException {
|
public void readKeys() throws IOException, InvalidKeySpecException {
|
||||||
if (privateKey != null || publicKey != null) return;
|
if (privateKey != null || publicKey != null) return;
|
||||||
Path dir = DirBridge.dir;
|
Path dir = DirBridge.dir;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
public class ClientModuleManager extends SimpleModuleManager {
|
public final class ClientModuleManager extends SimpleModuleManager {
|
||||||
public ClientModuleManager() {
|
public ClientModuleManager() {
|
||||||
super(null, null, Launcher.getConfig().trustManager);
|
super(null, null, Launcher.getConfig().trustManager);
|
||||||
}
|
}
|
||||||
|
@ -23,11 +23,6 @@ public void autoload(Path dir) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public LauncherModule loadModule(Path file) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LauncherModule loadModule(LauncherModule module) {
|
public LauncherModule loadModule(LauncherModule module) {
|
||||||
return super.loadModule(module);
|
return super.loadModule(module);
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package pro.gravit.launcher.debug;
|
||||||
|
|
||||||
|
import pro.gravit.launcher.LauncherTrustManager;
|
||||||
|
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
|
|
||||||
|
public class DebugLauncherTrustManager extends LauncherTrustManager {
|
||||||
|
private final TrustDebugMode mode;
|
||||||
|
public DebugLauncherTrustManager(X509Certificate[] trustSigners) {
|
||||||
|
super(trustSigners);
|
||||||
|
this.mode = null;
|
||||||
|
}
|
||||||
|
public DebugLauncherTrustManager() {
|
||||||
|
super(new X509Certificate[0]);
|
||||||
|
this.mode = null;
|
||||||
|
}
|
||||||
|
public DebugLauncherTrustManager(TrustDebugMode mode) {
|
||||||
|
super(new X509Certificate[0]);
|
||||||
|
this.mode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum TrustDebugMode {
|
||||||
|
TRUST_ALL
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CheckClassResult checkCertificates(X509Certificate[] certs, CertificateChecker checker) {
|
||||||
|
if(mode == TrustDebugMode.TRUST_ALL) return new CheckClassResult(CheckClassResultType.SUCCESS, null, null);
|
||||||
|
return super.checkCertificates(certs, checker);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
package pro.gravit.launcher.debug;
|
||||||
|
|
||||||
|
import pro.gravit.launcher.Launcher;
|
||||||
|
import pro.gravit.launcher.LauncherConfig;
|
||||||
|
import pro.gravit.launcher.LauncherEngine;
|
||||||
|
import pro.gravit.launcher.client.ClientLauncherCoreModule;
|
||||||
|
import pro.gravit.launcher.client.ClientModuleManager;
|
||||||
|
import pro.gravit.launcher.managers.ConsoleManager;
|
||||||
|
import pro.gravit.launcher.modules.LauncherModule;
|
||||||
|
import pro.gravit.launcher.modules.events.PreConfigPhase;
|
||||||
|
import pro.gravit.utils.helper.LogHelper;
|
||||||
|
|
||||||
|
import java.lang.invoke.MethodHandles;
|
||||||
|
import java.lang.invoke.MethodType;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
public class DebugMain {
|
||||||
|
public static final AtomicBoolean IS_DEBUG = new AtomicBoolean(false);
|
||||||
|
public static String webSocketURL = System.getProperty("launcherdebug.websocket", "ws://localhost:9274/api");
|
||||||
|
public static String projectName = System.getProperty("launcherdebug.projectname", "Minecraft");
|
||||||
|
public static String[] moduleClasses = System.getProperty("launcherdebug.modules", "").split(",");
|
||||||
|
public static String[] moduleFiles = System.getProperty("launcherdebug.modulefiles", "").split(",");
|
||||||
|
public static LauncherConfig.LauncherEnvironment environment = LauncherConfig.LauncherEnvironment.valueOf(System.getProperty("launcherdebug.env", "STD"));
|
||||||
|
public static void main(String[] args) throws Throwable {
|
||||||
|
LogHelper.printVersion("Launcher");
|
||||||
|
LogHelper.printLicense("Launcher");
|
||||||
|
IS_DEBUG.set(true);
|
||||||
|
LogHelper.info("Launcher start in DEBUG mode (Only for developers)");
|
||||||
|
LogHelper.debug("Initialization LauncherConfig");
|
||||||
|
LauncherConfig config = new LauncherConfig(webSocketURL, new HashMap<>(), projectName, environment, new DebugLauncherTrustManager(DebugLauncherTrustManager.TrustDebugMode.TRUST_ALL));
|
||||||
|
Launcher.setConfig(config);
|
||||||
|
Launcher.applyLauncherEnv(environment);
|
||||||
|
LauncherEngine.modulesManager = new ClientModuleManager();
|
||||||
|
LauncherEngine.modulesManager.loadModule(new ClientLauncherCoreModule());
|
||||||
|
for(String moduleClassName : moduleClasses) {
|
||||||
|
if(moduleClassName.isEmpty()) continue;
|
||||||
|
LauncherEngine.modulesManager.loadModule(newModule(moduleClassName));
|
||||||
|
}
|
||||||
|
for(String moduleFileName : moduleFiles) {
|
||||||
|
if(moduleFileName.isEmpty()) continue;
|
||||||
|
LauncherEngine.modulesManager.loadModule(Paths.get(moduleFileName));
|
||||||
|
}
|
||||||
|
LauncherEngine.modulesManager.initModules(null);
|
||||||
|
LauncherEngine.initGson(LauncherEngine.modulesManager);
|
||||||
|
ConsoleManager.initConsole();
|
||||||
|
LauncherEngine.modulesManager.invokeEvent(new PreConfigPhase());
|
||||||
|
LogHelper.debug("Initialization LauncherEngine");
|
||||||
|
LauncherEngine instance = LauncherEngine.newInstance();
|
||||||
|
instance.start(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static LauncherModule newModule(String className) throws ClassNotFoundException, InvocationTargetException {
|
||||||
|
Class<? extends LauncherModule> clazz = (Class<? extends LauncherModule>) Class.forName(className);
|
||||||
|
try {
|
||||||
|
return (LauncherModule) MethodHandles.publicLookup().findConstructor(clazz, MethodType.methodType(void.class)).invoke();
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
throw new InvocationTargetException(throwable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -98,6 +98,21 @@ public LauncherConfig(String address, ECPublicKey publicKey, Map<String, byte[]>
|
||||||
trustManager = null;
|
trustManager = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LauncherConfig(String address, Map<String, byte[]> runtime, String projectName, LauncherEnvironment env, LauncherTrustManager trustManager) {
|
||||||
|
this.address = address;
|
||||||
|
this.runtime = Collections.unmodifiableMap(new HashMap<>(runtime));
|
||||||
|
this.projectName = projectName;
|
||||||
|
this.clientPort = 32148;
|
||||||
|
this.publicKey = null;
|
||||||
|
this.trustManager = trustManager;
|
||||||
|
environment = env;
|
||||||
|
guardType = "no";
|
||||||
|
isWarningMissArchJava = true;
|
||||||
|
secureCheckSalt = null;
|
||||||
|
secureCheckHash = null;
|
||||||
|
passwordEncryptKey = null;
|
||||||
|
}
|
||||||
|
|
||||||
public static void initModules(LauncherModulesManager modulesManager) {
|
public static void initModules(LauncherModulesManager modulesManager) {
|
||||||
for (Class<?> clazz : modulesClasses)
|
for (Class<?> clazz : modulesClasses)
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
id 'org.openjfx.javafxplugin' version '0.0.8' apply false
|
id 'org.openjfx.javafxplugin' version '0.0.8' apply false
|
||||||
}
|
}
|
||||||
group = 'pro.gravit.launcher'
|
group = 'pro.gravit.launcher'
|
||||||
version = '5.1.10'
|
version = '5.1.11-SNAPSHOT'
|
||||||
|
|
||||||
apply from: 'props.gradle'
|
apply from: 'props.gradle'
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue