mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-05-12 03:56:33 +03:00
[FEATURE] Support runCompatClasses in ServerWrapperInlineInitializer
This commit is contained in:
parent
b41e8db336
commit
2fea94071b
2 changed files with 16 additions and 11 deletions
|
@ -142,6 +142,19 @@ public void connect() throws Exception {
|
|||
}
|
||||
ClientService.nativePath = config.nativesDir;
|
||||
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 {
|
||||
|
@ -240,18 +253,9 @@ public void run(String... args) throws Throwable {
|
|||
}
|
||||
ClientService.classLoaderControl = classLoaderControl;
|
||||
ClientService.baseURLs = classLoaderControl.getURLs();
|
||||
if(config.configServiceSettings != null) {
|
||||
config.configServiceSettings.apply();
|
||||
}
|
||||
LogHelper.info("Start Minecraft Server");
|
||||
try {
|
||||
if(config.compatClasses != null) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
runCompatClasses();
|
||||
LogHelper.debug("Invoke main method %s with %s", classname, launch.getClass().getName());
|
||||
launch.launch(config.mainclass, config.mainmodule, Arrays.asList(real_args));
|
||||
} catch (Throwable e) {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package pro.gravit.launcher.server;
|
||||
|
||||
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.initialize();
|
||||
ServerWrapper.wrapper.connect();
|
||||
ServerWrapper.wrapper.runCompatClasses();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue