예제 #1
0
  /**
   * Creates a new server on TCP port 25565 and starts listening for connections.
   *
   * @param args The command-line arguments.
   */
  public static void main(String[] args) {
    try {
      storeQueue.start();

      if (!configDir.exists() || !configDir.isDirectory()) configDir.mkdirs();
      config.load();
      config.options().indent(4);
      ConfigurationSerialization.registerClass(GlowOfflinePlayer.class);

      GlowServer server = new GlowServer();
      server.start();
      List<String> binds = config.getStringList("server.bind");
      boolean hasBound = false;
      if (binds != null) {
        for (String bind : binds) {
          String[] split = bind.split("@");
          if (split.length != 2) {
            split = bind.split(":");
          }
          if (split.length > 2) continue;
          int port = 25565;
          try {
            if (split.length > 1) {
              port = Integer.parseInt(split[1]);
            }
          } catch (NumberFormatException e) {
          }
          server.bind(new InetSocketAddress(split[0], port));
          hasBound = true;
        }
      }
      if (!hasBound) {
        server.bind(new InetSocketAddress(config.getInt("server.port", 25565)));
      }
      logger.info("Ready for connections.");
    } catch (Throwable t) {
      logger.log(Level.SEVERE, "Error during server startup.", t);
    }
  }
예제 #2
0
  /**
   * Creates a new server on TCP port 25565 and starts listening for connections.
   *
   * @param args The command-line arguments.
   */
  public static void main(String[] args) {
    try {
      ConfigurationSerialization.registerClass(GlowOfflinePlayer.class);
      GlowPotionEffect.register();

      // parse arguments and read config
      final ServerConfig config = parseArguments(args);
      if (config == null) {
        return;
      }

      // start server
      final GlowServer server = new GlowServer(config);
      server.start();
      server.bind();
      server.bindQuery();
      server.bindRcon();
      logger.info("Ready for connections.");
    } catch (Throwable t) {
      logger.log(Level.SEVERE, "Error during server startup.", t);
      System.exit(1);
    }
  }