Basic Quick Play support

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad 2023-06-12 12:08:18 +01:00
parent 3dccc38f42
commit aaab95ba55
2 changed files with 26 additions and 6 deletions

View File

@ -564,8 +564,15 @@ QStringList MinecraftInstance::processMinecraftArgs(
if (serverToJoin && !serverToJoin->address.isEmpty()) if (serverToJoin && !serverToJoin->address.isEmpty())
{ {
args_pattern += " --server " + serverToJoin->address; if (profile->hasTrait("quickPlay"))
args_pattern += " --port " + QString::number(serverToJoin->port); {
args_pattern += " --quickPlayMultiplayer " + serverToJoin->address + ':' + QString::number(serverToJoin->port);
}
else
{
args_pattern += " --server " + serverToJoin->address;
args_pattern += " --port " + QString::number(serverToJoin->port);
}
} }
QMap<QString, QString> token_mapping; QMap<QString, QString> token_mapping;

View File

@ -55,14 +55,21 @@
package org.prismlauncher.launcher.impl; package org.prismlauncher.launcher.impl;
import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandle;
import java.util.Collections;
import java.util.List;
import org.prismlauncher.utils.Parameters; import org.prismlauncher.utils.Parameters;
import org.prismlauncher.utils.ReflectionUtils; import org.prismlauncher.utils.ReflectionUtils;
public final class StandardLauncher extends AbstractLauncher { public final class StandardLauncher extends AbstractLauncher {
private final boolean quickPlaySupported;
public StandardLauncher(Parameters params) { public StandardLauncher(Parameters params) {
super(params); super(params);
List<String> traits = params.getList("traits", Collections.<String>emptyList());
quickPlaySupported = traits.contains("quickPlay");
} }
@Override @Override
@ -77,10 +84,16 @@ public final class StandardLauncher extends AbstractLauncher {
} }
if (serverAddress != null) { if (serverAddress != null) {
gameArgs.add("--server"); if (quickPlaySupported) {
gameArgs.add(serverAddress); // as of 23w14a
gameArgs.add("--port"); gameArgs.add("--quickPlayMultiplayer");
gameArgs.add(serverPort); gameArgs.add(serverAddress + ':' + serverPort);
} else {
gameArgs.add("--server");
gameArgs.add(serverAddress);
gameArgs.add("--port");
gameArgs.add(serverPort);
}
} }
// find and invoke the main method // find and invoke the main method