Java Code Examples for org.bukkit.event.weather.WeatherChangeEvent#setCancelled()
The following examples show how to use
org.bukkit.event.weather.WeatherChangeEvent#setCancelled() .
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: WeatherListener.java From BedwarsRel with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onWeatherEvent(WeatherChangeEvent we) { if (we.isCancelled()) { return; } List<Game> games = BedwarsRel.getInstance().getGameManager().getGamesByWorld(we.getWorld()); if (games.size() == 0) { return; } for (Game game : games) { if (game.getState() != GameState.STOPPED) { we.setCancelled(true); break; } } }
Example 2
Source File: GlobalListener.java From RedProtect with GNU General Public License v3.0 | 6 votes |
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL) public void onWeatherChange(WeatherChangeEvent e) { RedProtect.get().logger.debug(LogLevel.DEFAULT, "GlobalListener - Is onChangeWeather event"); World w = e.getWorld(); if (!RedProtect.get().config.globalFlagsRoot().worlds.get(w.getName()).weather.allow_weather) { int attempts = RedProtect.get().config.globalFlagsRoot().worlds.get(w.getName()).weather.attempts_before_rain; if (e.toWeatherState()) { if (!rainCounter.containsKey(w)) { rainCounter.put(w, attempts); e.setCancelled(true); } else { int acTry = rainCounter.get(w); if (acTry - 1 <= 0) { Bukkit.getScheduler().runTaskLater(RedProtect.get(), () -> w.setWeatherDuration(RedProtect.get().config.globalFlagsRoot().worlds.get(w.getName()).weather.rain_time * 20), 40); rainCounter.put(w, attempts); } else { rainCounter.put(w, acTry - 1); e.setCancelled(true); } } } } }
Example 3
Source File: DWorldListener.java From DungeonsXL with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onWeatherChange(WeatherChangeEvent event) { InstanceWorld instance = plugin.getInstanceWorld(event.getWorld()); if (instance instanceof EditWorld && event.toWeatherState()) { event.setCancelled(true); } else if (instance instanceof GameWorld) { Boolean raining = ((GameWorld) instance).getDungeon().getRules().getState(GameRule.RAIN); if (raining == null) { return; } if ((raining && !event.toWeatherState()) || (!raining && event.toWeatherState())) { event.setCancelled(true); } } }
Example 4
Source File: NoWeather.java From HubBasics with GNU Lesser General Public License v3.0 | 5 votes |
@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); } }
Example 5
Source File: EnvironmentControlListener.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@EventHandler public void noWeather(final WeatherChangeEvent event) { event.setCancelled(true); }
Example 6
Source File: NoWeatherChangeFeature.java From VoxelGamesLibv2 with MIT License | 4 votes |
@EventHandler public void onWeatherChange(WeatherChangeEvent e) { if (e.getWorld().getName().equals(world.getName())) { e.setCancelled(true); } }
Example 7
Source File: ServerListener.java From ZombieEscape with GNU General Public License v2.0 | 4 votes |
@EventHandler public void onWeather(WeatherChangeEvent event) { event.setCancelled(true); }
Example 8
Source File: WorldFreeze.java From CardinalPGM with MIT License | 4 votes |
@EventHandler public void onWeatherChange(WeatherChangeEvent event) { event.setCancelled(true); }
Example 9
Source File: UHPluginListener.java From KTP with GNU General Public License v3.0 | 4 votes |
@EventHandler public void onWeatherChange(WeatherChangeEvent ev) { if (!p.getConfig().getBoolean("weather")) { ev.setCancelled(true); } }