Esempio n. 1
0
  /** Starts this server. */
  public void start() {
    // Config should have already loaded by this point, but to be safe...
    config.load();
    consoleManager.setupConsole();

    // Load player lists
    opsList.load();
    whitelist.load();
    banManager.load();

    // Start loading plugins
    loadPlugins();

    // Begin registering permissions
    DefaultPermissions.registerCorePermissions();

    // Register these first so they're usable while the worlds are loading
    GlowCommandMap.initGlowPermissions(this);
    commandMap.register(new MeCommand(this));
    commandMap.register(new ColorCommand(this));
    commandMap.register(new KickCommand(this));
    commandMap.register(new ListCommand(this));
    commandMap.register(new TimeCommand(this));
    commandMap.register(new WhitelistCommand(this));
    commandMap.register(new BanCommand(this));
    commandMap.register(new GameModeCommand(this));
    commandMap.register(new OpCommand(this));
    commandMap.register(new DeopCommand(this));
    commandMap.register(new StopCommand(this));
    commandMap.register(new SaveCommand(this));
    commandMap.register(new SayCommand(this));
    commandMap.removeAllOfType(ReloadCommand.class);
    commandMap.register(new ReloadCommand(this));
    commandMap.register(new HelpCommand(this, commandMap.getKnownCommands(false)));

    enablePlugins(PluginLoadOrder.STARTUP);

    // Create worlds
    String world = config.getString("server.world-name", "world");
    createWorld(WorldCreator.name(world).environment(Environment.NORMAL));
    if (getAllowNether()) {
      createWorld(WorldCreator.name(world + "_nether").environment(Environment.NETHER));
    }
    if (getAllowEnd()) {
      createWorld(WorldCreator.name(world + "_the_end").environment(Environment.THE_END));
    }

    // Finish loading plugins
    enablePlugins(PluginLoadOrder.POSTWORLD);
    commandMap.registerServerAliases();
    consoleManager.refreshCommands();
  }
Esempio n. 2
0
  /** Stops this server. */
  public void shutdown() {
    // This is so we don't run this twice (/stop and actual shutdown)
    if (isShuttingDown) return;
    isShuttingDown = true;
    logger.info("The server is shutting down...");

    monitor.interrupt();

    // Stop scheduler and disable plugins
    scheduler.stop();
    pluginManager.clearPlugins();

    // Kick (and save) all players
    for (Player player : getOnlinePlayers()) {
      player.kickPlayer("Server shutting down.");
    }

    // Save worlds
    for (World world : getWorlds()) {
      unloadWorld(world, true);
    }
    storeQueue.end();

    // Gracefully stop Netty
    group.close();
    bootstrap.getFactory().releaseExternalResources();

    // And finally kill the console
    consoleManager.stop();
  }
Esempio n. 3
0
  /** Stops this server. */
  @Override
  public void shutdown() {
    // Just in case this gets called twice
    if (isShuttingDown) {
      return;
    }
    isShuttingDown = true;
    logger.info("The server is shutting down...");

    // Disable plugins
    pluginManager.clearPlugins();

    // Kick all players (this saves their data too)
    for (Player player : getOnlinePlayers()) {
      player.kickPlayer(getShutdownMessage());
    }

    // Stop the network servers - starts the shutdown process
    // It may take a second or two for Netty to totally clean up
    networkServer.shutdown();
    if (queryServer != null) {
      queryServer.shutdown();
    }
    if (rconServer != null) {
      rconServer.shutdown();
    }

    // Save worlds
    for (World world : getWorlds()) {
      logger.info("Saving world: " + world.getName());
      unloadWorld(world, true);
    }

    // Stop scheduler and console
    scheduler.stop();
    consoleManager.stop();

    // Wait for a while and terminate any rogue threads
    new ShutdownMonitorThread().start();
  }
Esempio n. 4
0
  /** Reloads the server, refreshing settings and plugin information */
  public void reload() {
    try {
      // Reload relevant configuration
      config.load();
      opsList.load();
      whitelist.load();

      // Reset crafting
      craftingManager.resetRecipes();

      // Load plugins
      loadPlugins();
      DefaultPermissions.registerCorePermissions();
      GlowCommandMap.initGlowPermissions(this);
      commandMap.registerAllPermissions();
      enablePlugins(PluginLoadOrder.STARTUP);
      enablePlugins(PluginLoadOrder.POSTWORLD);
      commandMap.registerServerAliases();
      consoleManager.refreshCommands();
    } catch (Exception ex) {
      logger.log(Level.SEVERE, "Uncaught error while reloading: {0}", ex.getMessage());
      ex.printStackTrace();
    }
  }
Esempio n. 5
0
 @Override
 public ConsoleCommandSender getConsoleSender() {
   return consoleManager.getSender();
 }
Esempio n. 6
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();
  }