示例#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);
 }