@Override @SuppressWarnings("unchecked") public Collection<ListenerInfo> getListeners() { Collection<Map<String, Object>> base = get("listeners", (Collection) Arrays.asList(new Map[] {new HashMap()})); Map<String, String> forcedDef = new HashMap<>(); forcedDef.put("pvp.md-5.net", "pvp"); Collection<ListenerInfo> ret = new HashSet<>(); for (Map<String, Object> val : base) { String motd = get("motd", "Another Bungee server", val); motd = ChatColor.translateAlternateColorCodes('&', motd); 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); InetSocketAddress address = Util.getAddr(host); Map<String, String> forced = new CaseInsensitiveMap<>(get("forced_hosts", forcedDef, val)); String textureURL = get("texture_url", null, val); int textureSize = get("texture_size", 16, val); TexturePackInfo texture = (textureURL == null) ? null : new TexturePackInfo(textureURL, textureSize); String tabListName = get("tab_list", "GLOBAL_PING", val); DefaultTabList value = DefaultTabList.valueOf(tabListName.toUpperCase()); if (value == null) { value = DefaultTabList.GLOBAL_PING; } ListenerInfo info = new ListenerInfo( address, motd, maxPlayers, tabListSize, defaultServer, fallbackServer, forceDefault, forced, texture, value.clazz); ret.add(info); } return ret; }
@Override @SuppressWarnings("unchecked") public Map<String, ServerInfo> getServers() { Map<String, Map<String, Object>> base = get("servers", (Map) Collections.singletonMap("lobby", new HashMap<>())); Map<String, ServerInfo> ret = new HashMap<>(); for (Map.Entry<String, Map<String, Object>> entry : base.entrySet()) { Map<String, Object> val = entry.getValue(); String name = entry.getKey(); String addr = get("address", "localhost:25565", val); boolean restricted = get("restricted", false, val); InetSocketAddress address = Util.getAddr(addr); ServerInfo info = ProxyServer.getInstance().constructServerInfo(name, address, restricted); ret.put(name, info); } return ret; }
@Override public void exception(Throwable t) throws Exception { con.disconnect(Util.exception(t)); }