From 5dfe83cf6dc10ca07088f03d5108015e9f657ee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Teichmann?= Date: Wed, 27 Mar 2013 16:37:56 +0100 Subject: [PATCH] add fallback_server so we can still have a different default server on first join --- .../main/java/net/md_5/bungee/api/config/ListenerInfo.java | 4 ++++ proxy/src/main/java/net/md_5/bungee/ServerConnector.java | 2 +- proxy/src/main/java/net/md_5/bungee/UserConnection.java | 4 ++-- proxy/src/main/java/net/md_5/bungee/config/YamlConfig.java | 3 ++- .../java/net/md_5/bungee/connection/DownstreamBridge.java | 4 ++-- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/api/src/main/java/net/md_5/bungee/api/config/ListenerInfo.java b/api/src/main/java/net/md_5/bungee/api/config/ListenerInfo.java index a9dcc1c5..c0f11496 100644 --- a/api/src/main/java/net/md_5/bungee/api/config/ListenerInfo.java +++ b/api/src/main/java/net/md_5/bungee/api/config/ListenerInfo.java @@ -32,6 +32,10 @@ public class ListenerInfo * Name of the server which users will be taken to by default. */ 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 * transferred to the default server on connect. 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 b0da801c..2933ccaf 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java @@ -164,7 +164,7 @@ public class ServerConnector extends PacketHandler @Override 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 ) { 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 fdc6ee7f..629c11f3 100644 --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java @@ -148,10 +148,10 @@ public final class UserConnection implements ProxiedPlayer if ( !future.isSuccess() ) { 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() ) ) { - 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 ); } else { diff --git a/proxy/src/main/java/net/md_5/bungee/config/YamlConfig.java b/proxy/src/main/java/net/md_5/bungee/config/YamlConfig.java index 0e0512d6..e3d779c6 100644 --- a/proxy/src/main/java/net/md_5/bungee/config/YamlConfig.java +++ b/proxy/src/main/java/net/md_5/bungee/config/YamlConfig.java @@ -181,6 +181,7 @@ public class YamlConfig implements ConfigurationAdapter int maxPlayers = get( "max_players", 1, val ); String defaultServer = get( "default_server", "lobby", val ); + String fallbackServer = get( "fallback_server", defaultServer, val ); boolean forceDefault = get( "force_default_server", false, val ); String host = get( "host", "0.0.0.0:25577", val ); int tabListSize = get( "tab_size", 60, val ); @@ -189,7 +190,7 @@ public class YamlConfig implements ConfigurationAdapter String textureURL = get( "texture_url", null, val ); int textureSize = get( "texture_size", 16, val ); 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 ); } diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java index ba414d1c..b24d3154 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java @@ -42,7 +42,7 @@ public class DownstreamBridge extends PacketHandler @Override 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 ) { con.connectNow( def ); @@ -313,7 +313,7 @@ public class DownstreamBridge extends PacketHandler @Override 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 ) { def = null;