Exemple #1
0
  /** @author CraftCraft */
  public void loadPlugins() {
    pluginManager.registerInterface(JavaPluginLoader.class);

    File pluginFolder = theServer.getFile("plugins");

    if (pluginFolder.exists()) {
      this.theLogger.info("Plugins are being loaded...");
      Plugin[] plugins = pluginManager.loadPlugins(pluginFolder);
      for (Plugin plugin : plugins) {
        try {
          String message = String.format("Loading %s", plugin.getDescription().getFullName());
          plugin.getLogger().info(message);
          plugin.onLoad();
        } catch (Throwable ex) {
          Logger.getLogger(CraftServer.class.getName())
              .log(
                  Level.SEVERE,
                  ex.getMessage()
                      + " initializing "
                      + plugin.getDescription().getFullName()
                      + " (Is it up to date?)",
                  ex);
        }
      }
    } else {
      theLogger.info("Plugin folder doesn't exist: " + pluginFolder.getAbsolutePath());
      pluginFolder.mkdir();
    }
  }
  public static File getWorldDirectory(MinecraftServer server) {
    if (server.isDedicatedServer()) {
      return server.getFile("world");
    } else {
      File worldsDir = getAnvilFile(server);
      if (worldsDir == null) return null;

      return new File(worldsDir, server.getFolderName());
    }
  }
Exemple #3
0
	@Override
	public void reload() {
		bukkitConfig = 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 = bukkitConfig.getInt("spawn-limits.monsters");
		animalSpawn = bukkitConfig.getInt("spawn-limits.animals");
		waterAnimalSpawn = bukkitConfig.getInt("spawn-limits.water-animals");
		warningState = WarningState.value(bukkitConfig.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);

	}
Exemple #4
0
	@Override
	public File getWorldContainer() {
		return theServer.getFile(theServer.worldServerForDimension(0).getWorldInfo().getWorldName());
	}