コード例 #1
0
  /** 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);
    }
  }
コード例 #2
0
 /**
  * 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);
   }
 }
コード例 #3
0
 /**
  * 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);
 }
コード例 #4
0
 @Override
 public int getWaterAnimalSpawnLimit() {
   return config.getInt(ServerConfig.Key.WATER_ANIMAL_LIMIT);
 }
コード例 #5
0
 @Override
 public int getAmbientSpawnLimit() {
   return config.getInt(ServerConfig.Key.AMBIENT_LIMIT);
 }
コード例 #6
0
 @Override
 public int getTicksPerMonsterSpawns() {
   return config.getInt(ServerConfig.Key.MONSTER_TICKS);
 }
コード例 #7
0
 @Override
 public int getMonsterSpawnLimit() {
   return config.getInt(ServerConfig.Key.MONSTER_LIMIT);
 }
コード例 #8
0
 @Override
 public int getTicksPerAnimalSpawns() {
   return config.getInt(ServerConfig.Key.ANIMAL_TICKS);
 }
コード例 #9
0
 @Override
 public long getConnectionThrottle() {
   return config.getInt(ServerConfig.Key.CONNECTION_THROTTLE);
 }
コード例 #10
0
 @Override
 public int getViewDistance() {
   return config.getInt(ServerConfig.Key.VIEW_DISTANCE);
 }
コード例 #11
0
 @Override
 public int getMaxPlayers() {
   return config.getInt(ServerConfig.Key.MAX_PLAYERS);
 }
コード例 #12
0
 @Override
 public int getPort() {
   return config.getInt(ServerConfig.Key.SERVER_PORT);
 }