mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-07-07 08:19:45 +03:00
Compare commits
4 commits
b41e8db336
...
911ca1e69f
Author | SHA1 | Date | |
---|---|---|---|
|
911ca1e69f | ||
|
90f74aaf25 | ||
|
880957fa9b | ||
|
2fea94071b |
7 changed files with 69 additions and 29 deletions
1
.github/workflows/push.yml
vendored
1
.github/workflows/push.yml
vendored
|
@ -39,6 +39,7 @@ jobs:
|
||||||
cp LaunchServer.jar ../../../artifacts/LaunchServer.jar
|
cp LaunchServer.jar ../../../artifacts/LaunchServer.jar
|
||||||
cd ../../..
|
cd ../../..
|
||||||
cp ServerWrapper/build/libs/ServerWrapper.jar artifacts/ServerWrapper.jar
|
cp ServerWrapper/build/libs/ServerWrapper.jar artifacts/ServerWrapper.jar
|
||||||
|
cp ServerWrapper/build/libs/ServerWrapper-inline.jar artifacts/ServerWrapperInline.jar
|
||||||
cp LauncherAuthlib/build/libs/LauncherAuthlib.jar artifacts/LauncherAuthlib.jar || true
|
cp LauncherAuthlib/build/libs/LauncherAuthlib.jar artifacts/LauncherAuthlib.jar || true
|
||||||
cp modules/*_module/build/libs/*.jar artifacts/modules || true
|
cp modules/*_module/build/libs/*.jar artifacts/modules || true
|
||||||
cp modules/*_lmodule/build/libs/*.jar artifacts/modules || true
|
cp modules/*_lmodule/build/libs/*.jar artifacts/modules || true
|
||||||
|
|
|
@ -28,6 +28,7 @@ public class DebugMain {
|
||||||
public static String webSocketURL = System.getProperty("launcherdebug.websocket", "ws://localhost:9274/api");
|
public static String webSocketURL = System.getProperty("launcherdebug.websocket", "ws://localhost:9274/api");
|
||||||
public static String projectName = System.getProperty("launcherdebug.projectname", "Minecraft");
|
public static String projectName = System.getProperty("launcherdebug.projectname", "Minecraft");
|
||||||
public static String unlockSecret = System.getProperty("launcherdebug.unlocksecret", "");
|
public static String unlockSecret = System.getProperty("launcherdebug.unlocksecret", "");
|
||||||
|
public static boolean disableConsole = Boolean.getBoolean("launcherdebug.disableConsole");
|
||||||
public static boolean offlineMode = Boolean.getBoolean("launcherdebug.offlinemode");
|
public static boolean offlineMode = Boolean.getBoolean("launcherdebug.offlinemode");
|
||||||
public static boolean disableAutoRefresh = Boolean.getBoolean("launcherdebug.disableautorefresh");
|
public static boolean disableAutoRefresh = Boolean.getBoolean("launcherdebug.disableautorefresh");
|
||||||
public static String[] moduleClasses = System.getProperty("launcherdebug.modules", "").split(",");
|
public static String[] moduleClasses = System.getProperty("launcherdebug.modules", "").split(",");
|
||||||
|
@ -37,6 +38,14 @@ public class DebugMain {
|
||||||
public static void main(String[] args) throws Throwable {
|
public static void main(String[] args) throws Throwable {
|
||||||
LogHelper.printVersion("Launcher");
|
LogHelper.printVersion("Launcher");
|
||||||
LogHelper.printLicense("Launcher");
|
LogHelper.printLicense("Launcher");
|
||||||
|
initialize();
|
||||||
|
LogHelper.debug("Initialization LauncherEngine");
|
||||||
|
LauncherEngine instance = LauncherEngine.newInstance(false, ClientRuntimeProvider.class);
|
||||||
|
instance.start(args);
|
||||||
|
LauncherEngine.exitLauncher(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void initialize() throws Exception {
|
||||||
IS_DEBUG.set(true);
|
IS_DEBUG.set(true);
|
||||||
LogHelper.info("Launcher start in DEBUG mode (Only for developers)");
|
LogHelper.info("Launcher start in DEBUG mode (Only for developers)");
|
||||||
LogHelper.debug("Initialization LauncherConfig");
|
LogHelper.debug("Initialization LauncherConfig");
|
||||||
|
@ -56,7 +65,9 @@ public static void main(String[] args) throws Throwable {
|
||||||
}
|
}
|
||||||
LauncherEngine.modulesManager.initModules(null);
|
LauncherEngine.modulesManager.initModules(null);
|
||||||
LauncherEngine.initGson(LauncherEngine.modulesManager);
|
LauncherEngine.initGson(LauncherEngine.modulesManager);
|
||||||
ConsoleManager.initConsole();
|
if(!disableConsole) {
|
||||||
|
ConsoleManager.initConsole();
|
||||||
|
}
|
||||||
LauncherEngine.modulesManager.invokeEvent(new PreConfigPhase());
|
LauncherEngine.modulesManager.invokeEvent(new PreConfigPhase());
|
||||||
RequestService service;
|
RequestService service;
|
||||||
if (offlineMode) {
|
if (offlineMode) {
|
||||||
|
@ -72,10 +83,6 @@ public static void main(String[] args) throws Throwable {
|
||||||
if(!disableAutoRefresh) {
|
if(!disableAutoRefresh) {
|
||||||
Request.startAutoRefresh();
|
Request.startAutoRefresh();
|
||||||
}
|
}
|
||||||
LogHelper.debug("Initialization LauncherEngine");
|
|
||||||
LauncherEngine instance = LauncherEngine.newInstance(false, ClientRuntimeProvider.class);
|
|
||||||
instance.start(args);
|
|
||||||
LauncherEngine.exitLauncher(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
package pro.gravit.launcher.runtime.debug;
|
||||||
|
|
||||||
|
public class DebugMainInlineInitializer {
|
||||||
|
public static void run() throws Exception {
|
||||||
|
DebugMain.initialize();
|
||||||
|
}
|
||||||
|
}
|
|
@ -116,15 +116,6 @@ private static void realMain(String[] args) throws Throwable {
|
||||||
|
|
||||||
// Verify ClientLauncher sign and classpath
|
// Verify ClientLauncher sign and classpath
|
||||||
LogHelper.debug("Verifying ClientLauncher sign and classpath");
|
LogHelper.debug("Verifying ClientLauncher sign and classpath");
|
||||||
Set<Path> ignoredPath = new HashSet<>();
|
|
||||||
List<Path> classpath = resolveClassPath(ignoredPath, clientDir, params.actions, params.profile)
|
|
||||||
.collect(Collectors.toCollection(ArrayList::new));
|
|
||||||
if(LogHelper.isDevEnabled()) {
|
|
||||||
for(var e : classpath) {
|
|
||||||
LogHelper.dev("Classpath entry %s", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<URL> classpathURLs = classpath.stream().map(IOHelper::toURL).toList();
|
|
||||||
// Start client with WatchService monitoring
|
// Start client with WatchService monitoring
|
||||||
RequestService service;
|
RequestService service;
|
||||||
if (params.offlineMode) {
|
if (params.offlineMode) {
|
||||||
|
@ -158,6 +149,18 @@ private static void realMain(String[] args) throws Throwable {
|
||||||
System.load(Paths.get(params.nativesDir).resolve(ClientService.findLibrary(e)).toAbsolutePath().toString());
|
System.load(Paths.get(params.nativesDir).resolve(ClientService.findLibrary(e)).toAbsolutePath().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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> classpath = resolveClassPath(ignoredPath, clientDir, params.actions, params.profile)
|
||||||
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
|
if(LogHelper.isDevEnabled()) {
|
||||||
|
for(var e : classpath) {
|
||||||
|
LogHelper.dev("Classpath entry %s", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<URL> classpathURLs = classpath.stream().map(IOHelper::toURL).toList();
|
||||||
if (classLoaderConfig == ClientProfile.ClassLoaderConfig.LAUNCHER || classLoaderConfig == ClientProfile.ClassLoaderConfig.MODULE) {
|
if (classLoaderConfig == ClientProfile.ClassLoaderConfig.LAUNCHER || classLoaderConfig == ClientProfile.ClassLoaderConfig.MODULE) {
|
||||||
if(JVMHelper.JVM_VERSION <= 11) {
|
if(JVMHelper.JVM_VERSION <= 11) {
|
||||||
launch = new LegacyLaunch();
|
launch = new LegacyLaunch();
|
||||||
|
@ -274,9 +277,11 @@ private static Stream<Path> resolveClassPathStream(Set<Path> ignorePaths, Path c
|
||||||
|
|
||||||
public static Stream<Path> resolveClassPath(Set<Path> ignorePaths, Path clientDir, Set<OptionalAction> actions, ClientProfile profile) throws IOException {
|
public static Stream<Path> resolveClassPath(Set<Path> ignorePaths, Path clientDir, Set<OptionalAction> actions, ClientProfile profile) throws IOException {
|
||||||
Stream<Path> result = resolveClassPathStream(ignorePaths, clientDir, profile.getClassPath());
|
Stream<Path> result = resolveClassPathStream(ignorePaths, clientDir, profile.getClassPath());
|
||||||
for (OptionalAction a : actions) {
|
if(actions != null) {
|
||||||
if (a instanceof OptionalActionClassPath)
|
for (OptionalAction a : actions) {
|
||||||
result = Stream.concat(result, resolveClassPathStream(ignorePaths, clientDir, ((OptionalActionClassPath) a).args));
|
if (a instanceof OptionalActionClassPath)
|
||||||
|
result = Stream.concat(result, resolveClassPathStream(ignorePaths, clientDir, ((OptionalActionClassPath) a).args));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,21 @@ pack project(':LauncherAPI')
|
||||||
exclude 'module-info.class'
|
exclude 'module-info.class'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.register('inlinejar', Jar) {
|
||||||
|
dependsOn configurations.runtimeClasspath
|
||||||
|
from {
|
||||||
|
configurations.runtimeClasspath.filter {! (it.name =~ /gson.*\.jar/ || it.name =~ /error_prone_annotations.*\.jar/)}.collect { it.isDirectory() ? it : zipTree(it) }
|
||||||
|
}
|
||||||
|
from {
|
||||||
|
sourceSets.main.output
|
||||||
|
}
|
||||||
|
archiveClassifier.set('inline')
|
||||||
|
manifest.attributes("Main-Class": mainClassName,
|
||||||
|
"Automatic-Module-Name": "ServerWrapper"
|
||||||
|
)
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
serverwrapperapi(MavenPublication) {
|
serverwrapperapi(MavenPublication) {
|
||||||
|
@ -94,4 +109,4 @@ pack project(':LauncherAPI')
|
||||||
sign publishing.publications.serverwrapperapi
|
sign publishing.publications.serverwrapperapi
|
||||||
}
|
}
|
||||||
|
|
||||||
assemble.dependsOn tasks.shadowJar
|
assemble.dependsOn tasks.shadowJar, tasks.inlinejar
|
||||||
|
|
|
@ -142,6 +142,19 @@ public void connect() throws Exception {
|
||||||
}
|
}
|
||||||
ClientService.nativePath = config.nativesDir;
|
ClientService.nativePath = config.nativesDir;
|
||||||
ConfigService.serverName = config.serverName;
|
ConfigService.serverName = config.serverName;
|
||||||
|
if(config.configServiceSettings != null) {
|
||||||
|
config.configServiceSettings.apply();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void runCompatClasses() throws Throwable {
|
||||||
|
if(config.compatClasses != null) {
|
||||||
|
for (String e : config.compatClasses) {
|
||||||
|
Class<?> clazz = classLoaderControl == null ? Class.forName(e) : classLoaderControl.getClass(e);
|
||||||
|
MethodHandle runMethod = MethodHandles.lookup().findStatic(clazz, "run", MethodType.methodType(void.class, ClassLoaderControl.class));
|
||||||
|
runMethod.invoke(classLoaderControl);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(String... args) throws Throwable {
|
public void run(String... args) throws Throwable {
|
||||||
|
@ -240,18 +253,9 @@ public void run(String... args) throws Throwable {
|
||||||
}
|
}
|
||||||
ClientService.classLoaderControl = classLoaderControl;
|
ClientService.classLoaderControl = classLoaderControl;
|
||||||
ClientService.baseURLs = classLoaderControl.getURLs();
|
ClientService.baseURLs = classLoaderControl.getURLs();
|
||||||
if(config.configServiceSettings != null) {
|
|
||||||
config.configServiceSettings.apply();
|
|
||||||
}
|
|
||||||
LogHelper.info("Start Minecraft Server");
|
LogHelper.info("Start Minecraft Server");
|
||||||
try {
|
try {
|
||||||
if(config.compatClasses != null) {
|
runCompatClasses();
|
||||||
for (String e : config.compatClasses) {
|
|
||||||
Class<?> clazz = classLoaderControl.getClass(e);
|
|
||||||
MethodHandle runMethod = MethodHandles.lookup().findStatic(clazz, "run", MethodType.methodType(void.class, ClassLoaderControl.class));
|
|
||||||
runMethod.invoke(classLoaderControl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
LogHelper.debug("Invoke main method %s with %s", classname, launch.getClass().getName());
|
LogHelper.debug("Invoke main method %s with %s", classname, launch.getClass().getName());
|
||||||
launch.launch(config.mainclass, config.mainmodule, Arrays.asList(real_args));
|
launch.launch(config.mainclass, config.mainmodule, Arrays.asList(real_args));
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package pro.gravit.launcher.server;
|
package pro.gravit.launcher.server;
|
||||||
|
|
||||||
public class ServerWrapperInlineInitializer {
|
public class ServerWrapperInlineInitializer {
|
||||||
public static void initialize() throws Exception {
|
public static void run() throws Throwable {
|
||||||
ServerWrapper.wrapper = new ServerWrapper(ServerWrapper.Config.class, ServerWrapper.configFile);
|
ServerWrapper.wrapper = new ServerWrapper(ServerWrapper.Config.class, ServerWrapper.configFile);
|
||||||
ServerWrapper.wrapper.initialize();
|
ServerWrapper.wrapper.initialize();
|
||||||
ServerWrapper.wrapper.connect();
|
ServerWrapper.wrapper.connect();
|
||||||
|
ServerWrapper.wrapper.runCompatClasses();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue