Exemplo n.º 1
0
  @Override
  public void shutdown() {

    theLogger.info("Stopping BukkitForge " + BukkitContainer.BF_FULL_VERSION);
    int pollCount = 0;
    while (pollCount < 50 && getScheduler().getActiveWorkers().size() > 0) {
      try {
        Thread.sleep(50);
      } catch (InterruptedException e) {
      }
      pollCount++;
    }

    List<BukkitWorker> overdueWorkers = getScheduler().getActiveWorkers();
    for (BukkitWorker worker : overdueWorkers) {
      Plugin plugin = worker.getOwner();
      String author = "<NoAuthorGiven>";
      if (plugin.getDescription().getAuthors().size() > 0) {
        author = plugin.getDescription().getAuthors().get(0);
      }
      getLogger()
          .log(
              Level.SEVERE,
              String.format(
                  "Nag author: '%s' of '%s' about the following: %s",
                  author,
                  plugin.getDescription().getName(),
                  "This plugin is not properly shutting down its async tasks when it is being reloaded.  This may cause conflicts with the newly loaded version of the plugin"));
    }
    getPluginManager().disablePlugins();
    // theServer.stopServer();

  }
Exemplo n.º 2
0
  public void run() {
    try {
      if (this.startServer()) {
        this.currentTime = getCurrentTimeMillis();
        long var1 = 0L;
        this.statusResponse.setServerDescription(new ChatComponentText(this.motd));
        this.statusResponse.setProtocolVersionInfo(
            new ServerStatusResponse.MinecraftProtocolVersionIdentifier("1.8", 47));
        this.addFaviconToStatusResponse(this.statusResponse);

        while (this.serverRunning) {
          long var48 = getCurrentTimeMillis();
          long var5 = var48 - this.currentTime;

          if (var5 > 2000L && this.currentTime - this.timeOfLastWarning >= 15000L) {
            logger.warn(
                "Can\'t keep up! Did the system time change, or is the server overloaded? Running {}ms behind, skipping {} tick(s)",
                new Object[] {Long.valueOf(var5), Long.valueOf(var5 / 50L)});
            var5 = 2000L;
            this.timeOfLastWarning = this.currentTime;
          }

          if (var5 < 0L) {
            logger.warn("Time ran backwards! Did the system time change?");
            var5 = 0L;
          }

          var1 += var5;
          this.currentTime = var48;

          if (this.worldServers[0].areAllPlayersAsleep()) {
            this.tick();
            var1 = 0L;
          } else {
            while (var1 > 50L) {
              var1 -= 50L;
              this.tick();
            }
          }

          Thread.sleep(Math.max(1L, 50L - var1));
          this.serverIsRunning = true;
        }
      } else {
        this.finalTick((CrashReport) null);
      }
    } catch (Throwable var46) {
      logger.error("Encountered an unexpected exception", var46);
      CrashReport var2 = null;

      if (var46 instanceof ReportedException) {
        var2 = this.addServerInfoToCrashReport(((ReportedException) var46).getCrashReport());
      } else {
        var2 =
            this.addServerInfoToCrashReport(
                new CrashReport("Exception in server tick loop", var46));
      }

      File var3 =
          new File(
              new File(this.getDataDirectory(), "crash-reports"),
              "crash-"
                  + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date())
                  + "-server.txt");

      if (var2.saveToFile(var3)) {
        logger.error("This crash report has been saved to: " + var3.getAbsolutePath());
      } else {
        logger.error("We were unable to save this crash report to disk.");
      }

      this.finalTick(var2);
    } finally {
      try {
        this.stopServer();
        this.serverStopped = true;
      } catch (Throwable var44) {
        logger.error("Exception stopping the server", var44);
      } finally {
        this.systemExitNow();
      }
    }
  }
Exemplo n.º 3
0
 public boolean isCallingFromMinecraftThread() {
   return Thread.currentThread() == this.serverThread;
 }
Exemplo n.º 4
0
  @Override
  public void reload() {
    configuration = YamlConfiguration.loadConfiguration(new File("bukkit.yml"));
    //

    if (theServer instanceof DedicatedServer) {
      PropertyManager config = new PropertyManager(theServer.getFile("server.properties"));
      ((DedicatedServer) theServer).settings = config;
    }

    //

    boolean animals = theServer.getCanSpawnAnimals();
    boolean monsters = theServer.worldServerForDimension(0).difficultySetting > 0;
    int difficulty = theServer.worldServerForDimension(0).difficultySetting;

    // theServer.pro
    /*theServer.setOnlineMode(theServer.isServerInOnlineMode());
    theServer.setCanSpawnAnimals(config.getBooleanProperty("spawn-animals", theServer.getCanSpawnAnimals()));
    theServer.setAllowPvp(config.getBooleanProperty("pvp", theServer.isPVPEnabled()));
    theServer.setAllowFlight(config.getBooleanProperty("allow-flight", theServer.isFlightAllowed()));
    theServer.setMOTD(config.getProperty("motd", theServer.getMOTD()));*/
    monsterSpawn = configuration.getInt("spawn-limits.monsters");
    animalSpawn = configuration.getInt("spawn-limits.animals");
    waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals");
    warningState = WarningState.value(configuration.getString("settings.deprecated-verbose"));
    // = bukkitConfig.getInt("ticks-per.autosave");

    for (WorldServer world : theServer.worldServers) {
      world.difficultySetting = difficulty;
      world.spawnHostileMobs = monsters;
      world.spawnPeacefulMobs = animals;
      /*if (this.getTicksPerAnimalSpawns() < 0) {
          world.ticksPerAnimalSpawns = 400;
      } else {
          world.ticksPerAnimalSpawns = this.getTicksPerAnimalSpawns();
      }

      if (this.getTicksPerMonsterSpawns() < 0) {
          world.ticksPerMonsterSpawns = 1;
      } else {
          world.ticksPerMonsterSpawns = this.getTicksPerMonsterSpawns();
      }*/
    }

    pluginManager.clearPlugins();
    commandMap.clearCommands();
    resetRecipes();

    int pollCount = 0;

    // Wait for at most 2.5 seconds for plugins to close their threads
    while (pollCount < 50 && getScheduler().getActiveWorkers().size() > 0) {
      try {
        Thread.sleep(50);
      } catch (InterruptedException e) {
      }
      pollCount++;
    }

    List<BukkitWorker> overdueWorkers = getScheduler().getActiveWorkers();
    for (BukkitWorker worker : overdueWorkers) {
      Plugin plugin = worker.getOwner();
      String author = "<NoAuthorGiven>";
      if (plugin.getDescription().getAuthors().size() > 0) {
        author = plugin.getDescription().getAuthors().get(0);
      }
      getLogger()
          .log(
              Level.SEVERE,
              String.format(
                  "Nag author: '%s' of '%s' about the following: %s",
                  author,
                  plugin.getDescription().getName(),
                  "This plugin is not properly shutting down its async tasks when it is being reloaded.  This may cause conflicts with the newly loaded version of the plugin"));
    }
    loadPlugins();
    enablePlugins(PluginLoadOrder.STARTUP);
    enablePlugins(PluginLoadOrder.POSTWORLD);
    // reload commands
    commandMap.doneLoadingPlugins((ServerCommandManager) theServer.getCommandManager());
  }