use of net.md_5.bungee.api.config.ConfigurationAdapter in project BungeeCord by SpigotMC.
the class Configuration method load.
public void load() {
ConfigurationAdapter adapter = ProxyServer.getInstance().getConfigurationAdapter();
adapter.load();
File fav = new File("server-icon.png");
if (fav.exists()) {
try {
favicon = Favicon.create(ImageIO.read(fav));
} catch (IOException | IllegalArgumentException ex) {
ProxyServer.getInstance().getLogger().log(Level.WARNING, "Could not load server icon", ex);
}
}
listeners = adapter.getListeners();
timeout = adapter.getInt("timeout", timeout);
uuid = adapter.getString("stats", uuid);
onlineMode = adapter.getBoolean("online_mode", onlineMode);
logCommands = adapter.getBoolean("log_commands", logCommands);
logPings = adapter.getBoolean("log_pings", logPings);
remotePingCache = adapter.getInt("remote_ping_cache", remotePingCache);
playerLimit = adapter.getInt("player_limit", playerLimit);
serverConnectTimeout = adapter.getInt("server_connect_timeout", serverConnectTimeout);
remotePingTimeout = adapter.getInt("remote_ping_timeout", remotePingTimeout);
throttle = adapter.getInt("connection_throttle", throttle);
throttleLimit = adapter.getInt("connection_throttle_limit", throttleLimit);
ipForward = adapter.getBoolean("ip_forward", ipForward);
compressionThreshold = adapter.getInt("network_compression_threshold", compressionThreshold);
preventProxyConnections = adapter.getBoolean("prevent_proxy_connections", preventProxyConnections);
forgeSupport = adapter.getBoolean("forge_support", forgeSupport);
disabledCommands = new CaseInsensitiveSet((Collection<String>) adapter.getList("disabled_commands", Arrays.asList("disabledcommandhere")));
Preconditions.checkArgument(listeners != null && !listeners.isEmpty(), "No listeners defined.");
Map<String, ServerInfo> newServers = adapter.getServers();
Preconditions.checkArgument(newServers != null && !newServers.isEmpty(), "No servers defined");
if (servers == null) {
servers = new CaseInsensitiveMap<>(newServers);
} else {
for (ServerInfo oldServer : servers.values()) {
// Don't allow servers to be removed
Preconditions.checkArgument(newServers.containsKey(oldServer.getName()), "Server %s removed on reload!", oldServer.getName());
}
// Add new servers
for (Map.Entry<String, ServerInfo> newServer : newServers.entrySet()) {
if (!servers.containsValue(newServer.getValue())) {
servers.put(newServer.getKey(), newServer.getValue());
}
}
}
for (ListenerInfo listener : listeners) {
for (int i = 0; i < listener.getServerPriority().size(); i++) {
String server = listener.getServerPriority().get(i);
Preconditions.checkArgument(servers.containsKey(server), "Server %s (priority %s) is not defined", server, i);
}
for (String server : listener.getForcedHosts().values()) {
if (!servers.containsKey(server)) {
ProxyServer.getInstance().getLogger().log(Level.WARNING, "Forced host server {0} is not defined", server);
}
}
}
}
Aggregations