Java Code Examples for org.bukkit.WeatherType#DOWNFALL

The following examples show how to use org.bukkit.WeatherType#DOWNFALL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WeatherOption.java    From SkyWarsReloaded with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void completeOption() {
	Vote weather = gameMap.getWeatherOption().getVoted();
	WeatherType w = WeatherType.CLEAR;
	if (weather != Vote.WEATHERSUN) {
		w = WeatherType.DOWNFALL;
	} 
	if (weather == Vote.WEATHERTHUNDER) {
		gameMap.setThunderStorm(true);
		gameMap.setNextStrike(Util.get().getRandomNum(3, 20));
		gameMap.setStrikeCounter(0);
	} else if (weather == Vote.WEATHERSNOW) {
		World world = gameMap.getAlivePlayers().get(0).getWorld();
		for (int x = -200; x < 200; x++) {
			for (int z = -200; z < 200; z++) {
				if (SkyWarsReloaded.getNMS().getVersion() < 13) {
					world.setBiome(x, z, Biome.valueOf("ICE_MOUNTAINS"));
				} else {
					world.setBiome(x, z, Biome.SNOWY_TUNDRA);
				}
			}
		}
		List<Chunk> chunks = Util.get().getChunks(world);
		for (Chunk chunk: chunks) {
			world.refreshChunk(chunk.getX(), chunk.getZ());
		}
	}
	for (Player player: gameMap.getAllPlayers()) {
		player.setPlayerWeather(w);
	}
}
 
Example 2
Source File: NoWeather.java    From HubBasics with GNU Lesser General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onWeather(WeatherChangeEvent event) {
    WeatherType type = this.worldStates.get(event.getWorld().getName());
    if (type == null) return;
    if (type == WeatherType.CLEAR && event.toWeatherState()) {
        event.setCancelled(true);
    } else if (type == WeatherType.DOWNFALL && !event.toWeatherState()) {
        event.setCancelled(true);
    }
}