add fallback_server so we can still have a different default server on first join

This commit is contained in:
Björn Teichmann 2013-03-27 16:37:56 +01:00 committed by md_5
parent fecaf76acf
commit 5dfe83cf6d
5 changed files with 11 additions and 6 deletions

View File

@ -32,6 +32,10 @@ public class ListenerInfo
* Name of the server which users will be taken to by default. * Name of the server which users will be taken to by default.
*/ */
private final String defaultServer; private final String defaultServer;
/**
* Name of the server which users will be taken when current server goes down.
*/
private final String fallbackServer;
/** /**
* Whether reconnect locations will be used, or else the user is simply * Whether reconnect locations will be used, or else the user is simply
* transferred to the default server on connect. * transferred to the default server on connect.

View File

@ -164,7 +164,7 @@ public class ServerConnector extends PacketHandler
@Override @Override
public void handle(PacketFFKick kick) throws Exception public void handle(PacketFFKick kick) throws Exception
{ {
ServerInfo def = bungee.getServerInfo( user.getPendingConnection().getListener().getDefaultServer() ); ServerInfo def = bungee.getServerInfo( user.getPendingConnection().getListener().getFallbackServer() );
if ( target == def ) if ( target == def )
{ {
def = null; def = null;

View File

@ -148,10 +148,10 @@ public final class UserConnection implements ProxiedPlayer
if ( !future.isSuccess() ) if ( !future.isSuccess() )
{ {
future.channel().close(); future.channel().close();
ServerInfo def = ProxyServer.getInstance().getServers().get( getPendingConnection().getListener().getDefaultServer() ); ServerInfo def = ProxyServer.getInstance().getServers().get( getPendingConnection().getListener().getFallbackServer() );
if ( retry & target != def && ( getServer() == null || def != getServer().getInfo() ) ) if ( retry & target != def && ( getServer() == null || def != getServer().getInfo() ) )
{ {
sendMessage( ChatColor.RED + "Could not connect to target server, you have been moved to the default server" ); sendMessage( ChatColor.RED + "Could not connect to target server, you have been moved to the lobby server" );
connect( def, false ); connect( def, false );
} else } else
{ {

View File

@ -181,6 +181,7 @@ public class YamlConfig implements ConfigurationAdapter
int maxPlayers = get( "max_players", 1, val ); int maxPlayers = get( "max_players", 1, val );
String defaultServer = get( "default_server", "lobby", val ); String defaultServer = get( "default_server", "lobby", val );
String fallbackServer = get( "fallback_server", defaultServer, val );
boolean forceDefault = get( "force_default_server", false, val ); boolean forceDefault = get( "force_default_server", false, val );
String host = get( "host", "0.0.0.0:25577", val ); String host = get( "host", "0.0.0.0:25577", val );
int tabListSize = get( "tab_size", 60, val ); int tabListSize = get( "tab_size", 60, val );
@ -189,7 +190,7 @@ public class YamlConfig implements ConfigurationAdapter
String textureURL = get( "texture_url", null, val ); String textureURL = get( "texture_url", null, val );
int textureSize = get( "texture_size", 16, val ); int textureSize = get( "texture_size", 16, val );
TexturePackInfo texture = ( textureURL == null ) ? null : new TexturePackInfo( textureURL, textureSize ); TexturePackInfo texture = ( textureURL == null ) ? null : new TexturePackInfo( textureURL, textureSize );
ListenerInfo info = new ListenerInfo( address, motd, maxPlayers, tabListSize, defaultServer, forceDefault, forced, texture ); ListenerInfo info = new ListenerInfo( address, motd, maxPlayers, tabListSize, defaultServer, fallbackServer, forceDefault, forced, texture );
ret.add( info ); ret.add( info );
} }

View File

@ -42,7 +42,7 @@ public class DownstreamBridge extends PacketHandler
@Override @Override
public void exception(Throwable t) throws Exception public void exception(Throwable t) throws Exception
{ {
ServerInfo def = bungee.getServerInfo( con.getPendingConnection().getListener().getDefaultServer() ); ServerInfo def = bungee.getServerInfo( con.getPendingConnection().getListener().getFallbackServer() );
if ( server.getInfo() != def ) if ( server.getInfo() != def )
{ {
con.connectNow( def ); con.connectNow( def );
@ -313,7 +313,7 @@ public class DownstreamBridge extends PacketHandler
@Override @Override
public void handle(PacketFFKick kick) throws Exception public void handle(PacketFFKick kick) throws Exception
{ {
ServerInfo def = bungee.getServerInfo( con.getPendingConnection().getListener().getDefaultServer() ); ServerInfo def = bungee.getServerInfo( con.getPendingConnection().getListener().getFallbackServer() );
if ( server.getInfo() == def ) if ( server.getInfo() == def )
{ {
def = null; def = null;