Handle removed servers in reconnect
This commit is contained in:
parent
385699380f
commit
317f286789
@ -1,5 +1,6 @@
|
|||||||
package net.md_5.bungee.api;
|
package net.md_5.bungee.api;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
public interface ReconnectHandler
|
public interface ReconnectHandler
|
||||||
@ -9,9 +10,9 @@ public interface ReconnectHandler
|
|||||||
* Gets the initial server name for a connecting player.
|
* Gets the initial server name for a connecting player.
|
||||||
*
|
*
|
||||||
* @param player the 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
|
* Save the server of this player before they disconnect so it can be
|
||||||
|
@ -156,9 +156,8 @@ public class InitialHandler extends PacketHandler implements Runnable, PendingCo
|
|||||||
Preconditions.checkState( thisState == State.LOGIN, "Not expecting LOGIN" );
|
Preconditions.checkState( thisState == State.LOGIN, "Not expecting LOGIN" );
|
||||||
|
|
||||||
UserConnection userCon = new UserConnection( socket, this, stream, handshake, forgeLogin, loginMessages );
|
UserConnection userCon = new UserConnection( socket, this, stream, handshake, forgeLogin, loginMessages );
|
||||||
String server = ProxyServer.getInstance().getReconnectHandler().getServer( userCon );
|
ServerInfo server = ProxyServer.getInstance().getReconnectHandler().getServer( userCon );
|
||||||
ServerInfo s = BungeeCord.getInstance().config.getServers().get( server );
|
userCon.connect( server, true );
|
||||||
userCon.connect( s, true );
|
|
||||||
|
|
||||||
thisState = State.FINISHED;
|
thisState = State.FINISHED;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.md_5.bungee;
|
package net.md_5.bungee;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.FileWriter;
|
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.ProxyServer;
|
||||||
import net.md_5.bungee.api.ReconnectHandler;
|
import net.md_5.bungee.api.ReconnectHandler;
|
||||||
import net.md_5.bungee.api.config.ListenerInfo;
|
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 net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
@ -47,16 +49,26 @@ public class YamlReconnectHandler implements ReconnectHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getServer(ProxiedPlayer player)
|
public ServerInfo getServer(ProxiedPlayer player)
|
||||||
{
|
{
|
||||||
ListenerInfo listener = player.getPendingConnection().getListener();
|
ListenerInfo listener = player.getPendingConnection().getListener();
|
||||||
|
String name;
|
||||||
if ( listener.isForceDefault() )
|
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() );
|
ServerInfo info = ProxyServer.getInstance().getServerInfo( name );
|
||||||
String server = ( forced == null ) ? data.get( key( player ) ) : forced;
|
if ( info == null )
|
||||||
return ( server != null ) ? server : listener.getDefaultServer();
|
{
|
||||||
|
info = ProxyServer.getInstance().getServerInfo( listener.getDefaultServer() );
|
||||||
|
}
|
||||||
|
Preconditions.checkState( info != null, "Default server not defined" );
|
||||||
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user