[FEATURE] Указание аргументов для сервера

This commit is contained in:
Gravit 2019-02-05 18:33:53 +07:00
parent 64cf9788d9
commit 795bca03a3
No known key found for this signature in database
GPG key ID: 061981E1E85D3216

View file

@ -152,14 +152,24 @@ public static void main(String... args) throws Throwable {
if (loader != null) mainClass = Class.forName(classname, true, loader);
else mainClass = Class.forName(classname);
MethodHandle mainMethod = MethodHandles.publicLookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class));
String[] real_args = new String[args.length - 1];
System.arraycopy(args, 1, real_args, 0, args.length - 1);
modulesManager.postInitModules();
LogHelper.info("ServerWrapper: Project %s, LaunchServer address: %s port %d. Title: %s", config.projectname, config.address, config.port, config.title);
LogHelper.info("Minecraft Version (for profile): %s", wrapper.profile == null ? "unknown" : wrapper.profile.getVersion().name);
LogHelper.info("Start Minecraft Server");
LogHelper.debug("Invoke main method %s", mainClass.getName());
mainMethod.invoke(real_args);
if(config.args == null)
{
String[] real_args = new String[args.length - 1];
System.arraycopy(args, 1, real_args, 0, args.length - 1);
Object[] args_array = { real_args };
mainMethod.invoke(args_array);
}
else
{
Object[] args_array = { config.args };
mainMethod.invoke(args_array);
}
}
private static void generateConfigIfNotExists() throws IOException {
@ -207,6 +217,7 @@ public static final class Config {
public String librariesDir;
public String mainclass;
public String login;
public String[] args;
public String password;
public LauncherConfig.LauncherEnvironment env;
}