From 57576912c162504f20e828098003e642a25c794f Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 21 Jan 2013 14:04:46 +1100 Subject: [PATCH] Add forced servers back. --- .../main/java/net/md_5/bungee/api/config/ListenerInfo.java | 6 ++++++ .../src/main/java/net/md_5/bungee/YamlReconnectHandler.java | 4 ++-- proxy/src/main/java/net/md_5/bungee/config/YamlConfig.java | 6 +++++- 3 files changed, 13 insertions(+), 3 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 150a79f3..7b0f0997 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 @@ -1,6 +1,7 @@ package net.md_5.bungee.api.config; import java.net.InetSocketAddress; +import java.util.Map; import lombok.Data; /** @@ -32,4 +33,9 @@ public class ListenerInfo * transferred to the default server on connect. */ private final boolean forceDefault; + /** + * A list of host to server name mappings which will force a user to be + * transferred depending on the host they connect to. + */ + private final Map forcedHosts; } 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 6f1ced11..50c60d71 100644 --- a/proxy/src/main/java/net/md_5/bungee/YamlReconnectHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/YamlReconnectHandler.java @@ -50,8 +50,8 @@ public class YamlReconnectHandler implements ReconnectHandler { return listener.getDefaultServer(); } - - String server = data.get(key(player)); + String forced = listener.getForcedHosts().get(player.getPendingConnection().getVirtualHost().getHostName()); + String server = (forced == null) ? data.get(key(player)) : forced; return (server != null) ? server : listener.getDefaultServer(); } 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 b28b1808..e36b9dfa 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 @@ -147,6 +147,9 @@ public class YamlConfig implements ConfigurationAdapter { new HashMap() })); + Map forcedDef = new HashMap<>(); + forcedDef.put("pvp.md-5.net", "pvp"); + Collection ret = new HashSet<>(); for (Map val : base) @@ -157,7 +160,8 @@ public class YamlConfig implements ConfigurationAdapter boolean forceDefault = get("force_default_server", false, val); String host = get("host", "0.0.0.0:25577", val); InetSocketAddress address = Util.getAddr(host); - ListenerInfo info = new ListenerInfo(address, motd, maxPlayers, defaultServer, forceDefault); + Map forced = get("forced_hosts", forcedDef, val); + ListenerInfo info = new ListenerInfo(address, motd, maxPlayers, defaultServer, forceDefault, forced); ret.add(info); }