diff --git a/api/src/main/java/net/md_5/bungee/api/ReconnectHandler.java b/api/src/main/java/net/md_5/bungee/api/ReconnectHandler.java index dd417587..0a90c123 100644 --- a/api/src/main/java/net/md_5/bungee/api/ReconnectHandler.java +++ b/api/src/main/java/net/md_5/bungee/api/ReconnectHandler.java @@ -1,5 +1,6 @@ package net.md_5.bungee.api; +import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.connection.ProxiedPlayer; public interface ReconnectHandler @@ -9,9 +10,9 @@ public interface ReconnectHandler * Gets the initial server name for a connecting player. * * @param player the connecting player - * @return the server name + * @return the server to connect to */ - public String getServer(ProxiedPlayer player); + public ServerInfo getServer(ProxiedPlayer player); /** * Save the server of this player before they disconnect so it can be diff --git a/proxy/src/main/java/net/md_5/bungee/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/InitialHandler.java index e0f79ea1..ab57c741 100644 --- a/proxy/src/main/java/net/md_5/bungee/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/InitialHandler.java @@ -156,9 +156,8 @@ public class InitialHandler extends PacketHandler implements Runnable, PendingCo Preconditions.checkState( thisState == State.LOGIN, "Not expecting LOGIN" ); UserConnection userCon = new UserConnection( socket, this, stream, handshake, forgeLogin, loginMessages ); - String server = ProxyServer.getInstance().getReconnectHandler().getServer( userCon ); - ServerInfo s = BungeeCord.getInstance().config.getServers().get( server ); - userCon.connect( s, true ); + ServerInfo server = ProxyServer.getInstance().getReconnectHandler().getServer( userCon ); + userCon.connect( server, true ); thisState = State.FINISHED; } diff --git a/proxy/src/main/java/net/md_5/bungee/YamlReconnectHandler.java b/proxy/src/main/java/net/md_5/bungee/YamlReconnectHandler.java index 5cadd9fa..048d73e9 100644 --- a/proxy/src/main/java/net/md_5/bungee/YamlReconnectHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/YamlReconnectHandler.java @@ -1,5 +1,6 @@ package net.md_5.bungee; +import com.google.common.base.Preconditions; import java.io.File; import java.io.FileReader; import java.io.FileWriter; @@ -11,6 +12,7 @@ import java.util.logging.Level; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ReconnectHandler; import net.md_5.bungee.api.config.ListenerInfo; +import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.connection.ProxiedPlayer; import org.yaml.snakeyaml.Yaml; @@ -47,16 +49,26 @@ public class YamlReconnectHandler implements ReconnectHandler } @Override - public String getServer(ProxiedPlayer player) + public ServerInfo getServer(ProxiedPlayer player) { ListenerInfo listener = player.getPendingConnection().getListener(); + String name; if ( listener.isForceDefault() ) { - return listener.getDefaultServer(); + name = listener.getDefaultServer(); + } else + { + String forced = listener.getForcedHosts().get( player.getPendingConnection().getVirtualHost().getHostName() ); + String server = ( forced == null ) ? data.get( key( player ) ) : forced; + name = ( server != null ) ? server : listener.getDefaultServer(); } - String forced = listener.getForcedHosts().get( player.getPendingConnection().getVirtualHost().getHostName() ); - String server = ( forced == null ) ? data.get( key( player ) ) : forced; - return ( server != null ) ? server : listener.getDefaultServer(); + ServerInfo info = ProxyServer.getInstance().getServerInfo( name ); + if ( info == null ) + { + info = ProxyServer.getInstance().getServerInfo( listener.getDefaultServer() ); + } + Preconditions.checkState( info != null, "Default server not defined" ); + return info; } @Override