Add forced servers back.

This commit is contained in:
md_5 2013-01-21 14:04:46 +11:00
parent c281f008c3
commit 57576912c1
3 changed files with 13 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package net.md_5.bungee.api.config; package net.md_5.bungee.api.config;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.Map;
import lombok.Data; import lombok.Data;
/** /**
@ -32,4 +33,9 @@ public class ListenerInfo
* transferred to the default server on connect. * transferred to the default server on connect.
*/ */
private final boolean forceDefault; 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<String, String> forcedHosts;
} }

View File

@ -50,8 +50,8 @@ public class YamlReconnectHandler implements ReconnectHandler
{ {
return listener.getDefaultServer(); return listener.getDefaultServer();
} }
String forced = listener.getForcedHosts().get(player.getPendingConnection().getVirtualHost().getHostName());
String server = data.get(key(player)); String server = (forced == null) ? data.get(key(player)) : forced;
return (server != null) ? server : listener.getDefaultServer(); return (server != null) ? server : listener.getDefaultServer();
} }

View File

@ -147,6 +147,9 @@ public class YamlConfig implements ConfigurationAdapter
{ {
new HashMap() new HashMap()
})); }));
Map<String, String> forcedDef = new HashMap<>();
forcedDef.put("pvp.md-5.net", "pvp");
Collection<ListenerInfo> ret = new HashSet<>(); Collection<ListenerInfo> ret = new HashSet<>();
for (Map<String, Object> val : base) for (Map<String, Object> val : base)
@ -157,7 +160,8 @@ public class YamlConfig implements ConfigurationAdapter
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);
InetSocketAddress address = Util.getAddr(host); InetSocketAddress address = Util.getAddr(host);
ListenerInfo info = new ListenerInfo(address, motd, maxPlayers, defaultServer, forceDefault); Map<String, String> forced = get("forced_hosts", forcedDef, val);
ListenerInfo info = new ListenerInfo(address, motd, maxPlayers, defaultServer, forceDefault, forced);
ret.add(info); ret.add(info);
} }