Pass mainclass and gameargs to the main game via system properties (#3692)
This commit is contained in:
commit
0f7cb916cc
1 changed files with 13 additions and 0 deletions
|
@ -97,6 +97,19 @@ public final class StandardLauncher extends AbstractLauncher {
|
|||
gameArgs.add(worldName);
|
||||
}
|
||||
|
||||
StringBuilder joinedGameArgs = new StringBuilder();
|
||||
for (String gameArg : gameArgs) {
|
||||
if (joinedGameArgs.length() > 0) {
|
||||
joinedGameArgs.append('\u001F'); // unit separator, designed for this purpose
|
||||
}
|
||||
joinedGameArgs.append(gameArg);
|
||||
}
|
||||
|
||||
// pass the real main class and game arguments in so mods can access them
|
||||
System.setProperty("org.prismlauncher.launch.mainclass", mainClassName);
|
||||
// unit separator ('\u001F') delimited list of game args
|
||||
System.setProperty("org.prismlauncher.launch.gameargs", joinedGameArgs.toString());
|
||||
|
||||
// find and invoke the main method
|
||||
MethodHandle method = ReflectionUtils.findMainMethod(mainClassName);
|
||||
method.invokeExact(gameArgs.toArray(new String[0]));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue