Fix bug in ConnectOther message

Credits to @Jay113355 for spotting this
This commit is contained in:
Andrew Steinborn 2020-04-21 06:23:04 -04:00
parent 24c9fc0ef1
commit 2b84d35798

View File

@ -15,6 +15,7 @@ import com.velocitypowered.proxy.protocol.util.ByteBufDataOutput;
import com.velocitypowered.proxy.server.VelocityRegisteredServer;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.Optional;
import java.util.StringJoiner;
import net.kyori.text.serializer.legacy.LegacyComponentSerializer;
@ -43,8 +44,11 @@ class BungeeCordMessageResponder {
String playerName = in.readUTF();
String serverName = in.readUTF();
proxy.getPlayer(playerName).flatMap(player -> proxy.getServer(serverName))
.ifPresent(server -> player.createConnectionRequest(server).fireAndForget());
Optional<Player> referencedPlayer = proxy.getPlayer(playerName);
Optional<RegisteredServer> referencedServer = proxy.getServer(serverName);
if (referencedPlayer.isPresent() && referencedServer.isPresent()) {
referencedPlayer.get().createConnectionRequest(referencedServer.get()).fireAndForget();
}
}
private void processIp(ByteBufDataInput in) {