From 2b84d35798a72f96427edf4cdf1c81bd17fa66e0 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Tue, 21 Apr 2020 06:23:04 -0400 Subject: [PATCH] Fix bug in ConnectOther message Credits to @Jay113355 for spotting this --- .../connection/backend/BungeeCordMessageResponder.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BungeeCordMessageResponder.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BungeeCordMessageResponder.java index 678c77e8f..911e803cd 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BungeeCordMessageResponder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BungeeCordMessageResponder.java @@ -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 referencedPlayer = proxy.getPlayer(playerName); + Optional referencedServer = proxy.getServer(serverName); + if (referencedPlayer.isPresent() && referencedServer.isPresent()) { + referencedPlayer.get().createConnectionRequest(referencedServer.get()).fireAndForget(); + } } private void processIp(ByteBufDataInput in) {