mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 16:41:46 +03:00
[FIX] ServerWrapper NPE
This commit is contained in:
parent
8fb1349487
commit
31b6ae35e7
7 changed files with 12 additions and 13 deletions
|
@ -6,9 +6,9 @@ public final class Version implements Comparable<Version> {
|
|||
|
||||
public static final int MAJOR = 5;
|
||||
public static final int MINOR = 3;
|
||||
public static final int PATCH = 1;
|
||||
public static final int PATCH = 2;
|
||||
public static final int BUILD = 1;
|
||||
public static final Version.Type RELEASE = Type.STABLE;
|
||||
public static final Version.Type RELEASE = Type.DEV;
|
||||
public final int major;
|
||||
public final int minor;
|
||||
public final int patch;
|
||||
|
|
|
@ -180,9 +180,9 @@ public void run(String... args) throws Throwable {
|
|||
break;
|
||||
}
|
||||
LogHelper.info("Start Minecraft Server");
|
||||
LogHelper.debug("Invoke main method %s with %s", config.mainclass, launch.getClass().getName());
|
||||
LogHelper.debug("Invoke main method %s with %s", classname, launch.getClass().getName());
|
||||
try {
|
||||
launch.run(config, real_args);
|
||||
launch.run(classname, config, real_args);
|
||||
} catch (Throwable e) {
|
||||
LogHelper.error(e);
|
||||
System.exit(-1);
|
||||
|
|
|
@ -13,10 +13,10 @@
|
|||
public class ClasspathLaunch implements Launch {
|
||||
@Override
|
||||
@SuppressWarnings("ConfusingArgumentToVarargsMethod")
|
||||
public void run(ServerWrapper.Config config, String[] args) throws Throwable {
|
||||
public void run(String mainclass, ServerWrapper.Config config, String[] args) throws Throwable {
|
||||
URL[] urls = config.classpath.stream().map(Paths::get).map(IOHelper::toURL).toArray(URL[]::new);
|
||||
ClassLoader ucl = new PublicURLClassLoader(urls);
|
||||
Class<?> mainClass = Class.forName(config.mainclass, true, ucl);
|
||||
Class<?> mainClass = Class.forName(mainclass, true, ucl);
|
||||
MethodHandle mainMethod = MethodHandles.lookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class));
|
||||
mainMethod.invoke(args);
|
||||
}
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
import pro.gravit.launcher.server.ServerWrapper;
|
||||
|
||||
public interface Launch {
|
||||
void run(ServerWrapper.Config config, String[] args) throws Throwable;
|
||||
void run(String mainclass, ServerWrapper.Config config, String[] args) throws Throwable;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
public class ModuleLaunch implements Launch {
|
||||
@Override
|
||||
public void run(ServerWrapper.Config config, String[] args) throws Throwable {
|
||||
public void run(String mainclass, ServerWrapper.Config config, String[] args) throws Throwable {
|
||||
throw new UnsupportedOperationException("Module system not supported");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
public class SimpleLaunch implements Launch {
|
||||
@Override
|
||||
@SuppressWarnings("ConfusingArgumentToVarargsMethod")
|
||||
public void run(ServerWrapper.Config config, String[] args) throws Throwable {
|
||||
Class<?> mainClass = Class.forName(config.mainclass);
|
||||
public void run(String mainclass, ServerWrapper.Config config, String[] args) throws Throwable {
|
||||
Class<?> mainClass = Class.forName(mainclass);
|
||||
MethodHandle mainMethod = MethodHandles.lookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class));
|
||||
mainMethod.invoke(args);
|
||||
}
|
||||
|
|
|
@ -13,12 +13,11 @@
|
|||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ModuleLaunch implements Launch {
|
||||
@Override
|
||||
@SuppressWarnings("ConfusingArgumentToVarargsMethod")
|
||||
public void run(ServerWrapper.Config config, String[] args) throws Throwable {
|
||||
public void run(String mainclass, ServerWrapper.Config config, String[] args) throws Throwable {
|
||||
URL[] urls = config.classpath.stream().map(Paths::get).map(IOHelper::toURL).toArray(URL[]::new);
|
||||
ClassLoader ucl = new PublicURLClassLoader(urls);
|
||||
// Create Module Layer
|
||||
|
@ -55,7 +54,7 @@ public void run(ServerWrapper.Config config, String[] args) throws Throwable {
|
|||
}
|
||||
// Start main class
|
||||
ClassLoader loader = mainModule.getClassLoader();
|
||||
Class<?> mainClass = Class.forName(config.mainclass, true, loader);
|
||||
Class<?> mainClass = Class.forName(mainclass, true, loader);
|
||||
MethodHandle mainMethod = MethodHandles.lookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class));
|
||||
mainMethod.invoke(args);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue