示例#1
0
  /** Binds the query server to the address specified in the configuration. */
  private void bindQuery() {
    if (!config.getBoolean(ServerConfig.Key.QUERY_ENABLED)) {
      return;
    }

    SocketAddress address = getBindAddress(ServerConfig.Key.QUERY_PORT);
    queryServer = new QueryServer(this, config.getBoolean(ServerConfig.Key.QUERY_PLUGINS));

    logger.info("Binding query to address: " + address + "...");
    ChannelFuture future = queryServer.bind(address);
    Channel channel = future.awaitUninterruptibly().channel();
    if (!channel.isActive()) {
      logger.warning("Failed to bind query. Address already in use?");
    }
  }
示例#2
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);
    }
  }
示例#3
0
  /** Binds the rcon server to the address specified in the configuration. */
  private void bindRcon() {
    if (!config.getBoolean(ServerConfig.Key.RCON_ENABLED)) {
      return;
    }

    SocketAddress address = getBindAddress(ServerConfig.Key.RCON_PORT);
    rconServer = new RconServer(this, config.getString(ServerConfig.Key.RCON_PASSWORD));

    logger.info("Binding rcon to address: " + address + "...");
    ChannelFuture future = rconServer.bind(address);
    Channel channel = future.awaitUninterruptibly().channel();
    if (!channel.isActive()) {
      logger.warning("Failed to bind rcon. Address already in use?");
    }
  }
示例#4
0
 /**
  * Get whether achievements should be announced.
  *
  * @return True if achievements should be announced in chat.
  */
 public boolean getAnnounceAchievements() {
   return config.getBoolean(ServerConfig.Key.ANNOUNCE_ACHIEVEMENTS);
 }
示例#5
0
 /**
  * Get whether to use color codes in Rcon responses.
  *
  * @return True if color codes will be present in Rcon responses
  */
 public boolean useRconColors() {
   return config.getBoolean(ServerConfig.Key.RCON_COLORS);
 }
示例#6
0
 /**
  * Get whether parsing of data provided by a proxy is enabled.
  *
  * @return True if a proxy is providing data to use.
  */
 public boolean getProxySupport() {
   return config.getBoolean(ServerConfig.Key.PROXY_SUPPORT);
 }
示例#7
0
 /**
  * Get whether worlds should keep their spawns loaded by default.
  *
  * @return Whether to keep spawns loaded by default.
  */
 public boolean keepSpawnLoaded() {
   return config.getBoolean(ServerConfig.Key.PERSIST_SPAWN);
 }
示例#8
0
  /** Starts this server. */
  public void start() {
    // Determine console mode and start reading input
    consoleManager.startConsole(config.getBoolean(ServerConfig.Key.USE_JLINE));
    consoleManager.startFile(config.getString(ServerConfig.Key.LOG_FILE));

    if (getProxySupport()) {
      if (getOnlineMode()) {
        logger.warning("Proxy support is enabled, but online mode is enabled.");
      } else {
        logger.info("Proxy support is enabled.");
      }
    } else if (!getOnlineMode()) {
      logger.warning(
          "The server is running in offline mode! Only do this if you know what you're doing.");
    }

    // Load player lists
    opsList.load();
    whitelist.load();
    nameBans.load();
    ipBans.load();

    // DRAGONET-Start
    this.dragonetServer = new DragonetServer(this);
    this.dragonetServer.initialize();
    // DRAGONET-End

    // Start loading plugins
    loadPlugins();
    enablePlugins(PluginLoadOrder.STARTUP);

    // Create worlds
    String name = config.getString(ServerConfig.Key.LEVEL_NAME);
    String seedString = config.getString(ServerConfig.Key.LEVEL_SEED);
    boolean structs = getGenerateStructures();
    WorldType type = WorldType.getByName(getWorldType());
    if (type == null) {
      type = WorldType.NORMAL;
    }

    long seed = new Random().nextLong();
    if (!seedString.isEmpty()) {
      try {
        long parsed = Long.parseLong(seedString);
        if (parsed != 0) {
          seed = parsed;
        }
      } catch (NumberFormatException ex) {
        seed = seedString.hashCode();
      }
    }

    createWorld(
        WorldCreator.name(name)
            .environment(Environment.NORMAL)
            .seed(seed)
            .type(type)
            .generateStructures(structs));
    if (getAllowNether()) {
      createWorld(
          WorldCreator.name(name + "_nether")
              .environment(Environment.NETHER)
              .seed(seed)
              .type(type)
              .generateStructures(structs));
    }
    if (getAllowEnd()) {
      createWorld(
          WorldCreator.name(name + "_the_end")
              .environment(Environment.THE_END)
              .seed(seed)
              .type(type)
              .generateStructures(structs));
    }

    // Finish loading plugins
    enablePlugins(PluginLoadOrder.POSTWORLD);
    commandMap.registerServerAliases();
    scheduler.start();
  }
示例#9
0
 @Override
 public boolean useExactLoginLocation() {
   return config.getBoolean(ServerConfig.Key.EXACT_LOGIN_LOCATION);
 }
示例#10
0
 @Override
 public boolean getAllowFlight() {
   return config.getBoolean(ServerConfig.Key.ALLOW_FLIGHT);
 }
示例#11
0
 @Override
 public boolean isHardcore() {
   return config.getBoolean(ServerConfig.Key.HARDCORE);
 }
示例#12
0
 @Override
 public boolean getGenerateStructures() {
   return config.getBoolean(ServerConfig.Key.GENERATE_STRUCTURES);
 }
示例#13
0
 @Override
 public boolean getAllowEnd() {
   return config.getBoolean(ServerConfig.Key.ALLOW_END);
 }
示例#14
0
 @Override
 public boolean getAllowNether() {
   return config.getBoolean(ServerConfig.Key.ALLOW_NETHER);
 }
示例#15
0
 @Override
 public boolean getOnlineMode() {
   return config.getBoolean(ServerConfig.Key.ONLINE_MODE);
 }