Ejemplo n.º 1
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);

	}