/** Load the server configuration. */ private void loadConfig() { config.load(); // modifiable values spawnRadius = config.getInt(ServerConfig.Key.SPAWN_RADIUS); whitelistEnabled = config.getBoolean(ServerConfig.Key.WHITELIST); idleTimeout = config.getInt(ServerConfig.Key.PLAYER_IDLE_TIMEOUT); craftingManager.initialize(); // special handling warnState = Warning.WarningState.value(config.getString(ServerConfig.Key.WARNING_STATE)); try { defaultGameMode = GameMode.valueOf(config.getString(ServerConfig.Key.GAMEMODE)); } catch (IllegalArgumentException | NullPointerException e) { defaultGameMode = GameMode.SURVIVAL; } // server icon defaultIcon = new GlowServerIcon(); try { File file = config.getFile("server-icon.png"); if (file.isFile()) { defaultIcon = new GlowServerIcon(file); } } catch (Exception e) { logger.log(Level.WARNING, "Failed to load server-icon.png", e); } }
/** * Get the SocketAddress to bind to for a specified service. * * @param portKey The configuration key for the port to use. * @return The SocketAddress */ private SocketAddress getBindAddress(ServerConfig.Key portKey) { String ip = getIp(); int port = config.getInt(portKey); if (ip.length() == 0) { return new InetSocketAddress(port); } else { return new InetSocketAddress(ip, port); } }
/** * Get the threshold to use for network compression defined in the config. * * @return The compression threshold, or -1 for no compression. */ public int getCompressionThreshold() { return config.getInt(ServerConfig.Key.COMPRESSION_THRESHOLD); }
@Override public int getWaterAnimalSpawnLimit() { return config.getInt(ServerConfig.Key.WATER_ANIMAL_LIMIT); }
@Override public int getAmbientSpawnLimit() { return config.getInt(ServerConfig.Key.AMBIENT_LIMIT); }
@Override public int getTicksPerMonsterSpawns() { return config.getInt(ServerConfig.Key.MONSTER_TICKS); }
@Override public int getMonsterSpawnLimit() { return config.getInt(ServerConfig.Key.MONSTER_LIMIT); }
@Override public int getTicksPerAnimalSpawns() { return config.getInt(ServerConfig.Key.ANIMAL_TICKS); }
@Override public long getConnectionThrottle() { return config.getInt(ServerConfig.Key.CONNECTION_THROTTLE); }
@Override public int getViewDistance() { return config.getInt(ServerConfig.Key.VIEW_DISTANCE); }
@Override public int getMaxPlayers() { return config.getInt(ServerConfig.Key.MAX_PLAYERS); }
@Override public int getPort() { return config.getInt(ServerConfig.Key.SERVER_PORT); }