diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java index 35574a17e..dda2876b5 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java @@ -131,6 +131,7 @@ public class ServerConnector extends PacketHandler // Remove from old servers user.getServer().setObsolete( true ); user.getServer().disconnect( "Quitting" ); + user.pendingConnects.remove( target ); } // TODO: Fix this? @@ -166,7 +167,7 @@ public class ServerConnector extends PacketHandler public void handle(PacketFFKick kick) throws Exception { ServerInfo def = bungee.getServerInfo( user.getPendingConnection().getListener().getFallbackServer() ); - if ( Objects.equals( target, def) ) + if ( Objects.equals( target, def ) ) { def = null; } diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java index 8dbf89828..07d5ab4ad 100644 --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java @@ -12,8 +12,10 @@ import io.netty.channel.socket.nio.NioSocketChannel; import java.net.InetSocketAddress; import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.logging.Level; import lombok.AccessLevel; import lombok.Getter; @@ -65,6 +67,7 @@ public final class UserConnection implements ProxiedPlayer private final Object switchMutex = new Object(); public PacketCCSettings settings; public final Scoreboard serverSentScoreboard = new Scoreboard(); + public final Set pendingConnects = new HashSet<>(); public UserConnection(BungeeCord bungee, Channel channel, PendingConnection pendingConnection, Packet2Handshake handshake, Packet1Login forgeLogin, List loginMessages) { @@ -121,6 +124,13 @@ public final class UserConnection implements ProxiedPlayer sendMessage( ChatColor.RED + "Cannot connect to server you are already on!" ); return; } + if ( pendingConnects.contains( target ) ) + { + sendMessage( ChatColor.RED + "Already connecting to this server!" ); + return; + } + + pendingConnects.add( target ); new Bootstrap() .channel( NioSocketChannel.class ) @@ -144,6 +154,8 @@ public final class UserConnection implements ProxiedPlayer if ( !future.isSuccess() ) { future.channel().close(); + pendingConnects.remove( target ); + ServerInfo def = ProxyServer.getInstance().getServers().get( getPendingConnection().getListener().getFallbackServer() ); if ( retry & target != def && ( getServer() == null || def != getServer().getInfo() ) ) {