Java 类org.bukkit.event.weather.WeatherChangeEvent 实例源码

项目:Uranium    文件:CraftWorld.java   
public void setStorm(boolean hasStorm) {
    CraftServer server = world.getServer();

    WeatherChangeEvent weather = new WeatherChangeEvent(this, hasStorm);
    server.getPluginManager().callEvent(weather);
    if (!weather.isCancelled()) {
        world.worldInfo.setRaining(hasStorm);

        // These numbers are from Minecraft
        if (hasStorm) {
            setWeatherDuration(rand.nextInt(12000) + 12000);
        } else {
            setWeatherDuration(rand.nextInt(168000) + 12000);
        }
    }
}
项目:Skript    文件:EvtWeatherChange.java   
@SuppressWarnings("null")
@Override
public boolean check(final Event e) {
    if (types == null)
        return true;
    if (!(e instanceof WeatherChangeEvent || e instanceof ThunderChangeEvent))
        return false;
    final boolean rain = e instanceof WeatherChangeEvent ? ((WeatherChangeEvent) e).toWeatherState() : ((ThunderChangeEvent) e).getWorld().hasStorm();
    final boolean thunder = e instanceof ThunderChangeEvent ? ((ThunderChangeEvent) e).toThunderState() : ((WeatherChangeEvent) e).getWorld().isThundering();
    return types.check(e, new Checker<WeatherType>() {
        @Override
        public boolean check(final WeatherType t) {
            return t.isWeather(rain, thunder);
        }
    });
}
项目:ThermosRebased    文件:CraftWorld.java   
public void setStorm(boolean hasStorm) {
    CraftServer server = world.getServer();

    WeatherChangeEvent weather = new WeatherChangeEvent(this, hasStorm);
    server.getPluginManager().callEvent(weather);
    if (!weather.isCancelled()) {
        world.worldInfo.setRaining(hasStorm);

        // These numbers are from Minecraft
        if (hasStorm) {
            setWeatherDuration(rand.nextInt(12000) + 12000);
        } else {
            setWeatherDuration(rand.nextInt(168000) + 12000);
        }
    }
}
项目:Thermos    文件:CraftWorld.java   
public void setStorm(boolean hasStorm) {
    CraftServer server = world.getServer();

    WeatherChangeEvent weather = new WeatherChangeEvent(this, hasStorm);
    server.getPluginManager().callEvent(weather);
    if (!weather.isCancelled()) {
        world.worldInfo.setRaining(hasStorm);

        // These numbers are from Minecraft
        if (hasStorm) {
            setWeatherDuration(rand.nextInt(12000) + 12000);
        } else {
            setWeatherDuration(rand.nextInt(168000) + 12000);
        }
    }
}
项目:KCauldron    文件:CraftWorld.java   
public void setStorm(boolean hasStorm) {
    CraftServer server = world.getServer();

    WeatherChangeEvent weather = new WeatherChangeEvent(this, hasStorm);
    server.getPluginManager().callEvent(weather);
    if (!weather.isCancelled()) {
        world.worldInfo.setRaining(hasStorm);

        // These numbers are from Minecraft
        if (hasStorm) {
            setWeatherDuration(rand.nextInt(12000) + 12000);
        } else {
            setWeatherDuration(rand.nextInt(168000) + 12000);
        }
    }
}
项目:CauldronGit    文件:CraftWorld.java   
public void setStorm(boolean hasStorm) {
    CraftServer server = world.getServer();

    WeatherChangeEvent weather = new WeatherChangeEvent(this, hasStorm);
    server.getPluginManager().callEvent(weather);
    if (!weather.isCancelled()) {
        world.worldInfo.setRaining(hasStorm);

        // These numbers are from Minecraft
        if (hasStorm) {
            setWeatherDuration(rand.nextInt(12000) + 12000);
        } else {
            setWeatherDuration(rand.nextInt(168000) + 12000);
        }
    }
}
项目:Cauldron-Old    文件:CraftWorld.java   
public void setStorm(boolean hasStorm) {
    CraftServer server = world.getServer();

    WeatherChangeEvent weather = new WeatherChangeEvent(this, hasStorm);
    server.getPluginManager().callEvent(weather);
    if (!weather.isCancelled()) {
        world.worldInfo.setRaining(hasStorm);

        // These numbers are from Minecraft
        if (hasStorm) {
            setWeatherDuration(rand.nextInt(12000) + 12000);
        } else {
            setWeatherDuration(rand.nextInt(168000) + 12000);
        }
    }
}
项目:Cauldron-Reloaded    文件:CraftWorld.java   
public void setStorm(boolean hasStorm) {
    CraftServer server = world.getServer();

    WeatherChangeEvent weather = new WeatherChangeEvent(this, hasStorm);
    server.getPluginManager().callEvent(weather);
    if (!weather.isCancelled()) {
        world.worldInfo.setRaining(hasStorm);

        // These numbers are from Minecraft
        if (hasStorm) {
            setWeatherDuration(rand.nextInt(12000) + 12000);
        } else {
            setWeatherDuration(rand.nextInt(168000) + 12000);
        }
    }
}
项目:BedwarsRel    文件:WeatherListener.java   
@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;
    }
  }
}
项目:RedProtect    文件:RPWorldListener.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onWeatherChange(WeatherChangeEvent e) {    
    World w = e.getWorld();
    int trys = RPConfig.getGlobalFlagInt(w.getName()+".rain.trys-before-rain");
    if (e.toWeatherState()){
        if (!rainCounter.containsKey(w)){
            rainCounter.put(w, trys);
            e.setCancelled(true);
        } else {
            int acTry = rainCounter.get(w);
            if (acTry-1 <= 0){    
                Bukkit.getScheduler().runTaskLater(RedProtect.get(), () -> w.setWeatherDuration(RPConfig.getGlobalFlagInt(w.getName()+".rain.duration")*20), 40);
                rainCounter.put(w, trys);
            } else {
                rainCounter.put(w, acTry-1);
                e.setCancelled(true);
            }
        }           
    }
}
项目:FFoKC    文件:CraftWorld.java   
public void setStorm(boolean hasStorm) {
    CraftServer server = world.getServer();

    WeatherChangeEvent weather = new WeatherChangeEvent(this, hasStorm);
    server.getPluginManager().callEvent(weather);
    if (!weather.isCancelled()) {
        world.worldInfo.setRaining(hasStorm);

        // These numbers are from Minecraft
        if (hasStorm) {
            setWeatherDuration(rand.nextInt(12000) + 12000);
        } else {
            setWeatherDuration(rand.nextInt(168000) + 12000);
        }
    }
}
项目:CraftBukkit    文件:CraftWorld.java   
public void setStorm(boolean hasStorm) {
    CraftServer server = world.getServer();

    WeatherChangeEvent weather = new WeatherChangeEvent(this, hasStorm);
    server.getPluginManager().callEvent(weather);
    if (!weather.isCancelled()) {
        world.worldData.setStorm(hasStorm);

        // These numbers are from Minecraft
        if (hasStorm) {
            setWeatherDuration(rand.nextInt(12000) + 12000);
        } else {
            setWeatherDuration(rand.nextInt(168000) + 12000);
        }
    }
}
项目:CraftBukkit    文件:WorldServer.java   
private void Y() {
    // CraftBukkit start
    WeatherChangeEvent weather = new WeatherChangeEvent(this.getWorld(), false);
    this.getServer().getPluginManager().callEvent(weather);

    ThunderChangeEvent thunder = new ThunderChangeEvent(this.getWorld(), false);
    this.getServer().getPluginManager().callEvent(thunder);
    if (!weather.isCancelled()) {
        this.worldData.setWeatherDuration(0);
        this.worldData.setStorm(false);
    }
    if (!thunder.isCancelled()) {
        this.worldData.setThunderDuration(0);
        this.worldData.setThundering(false);
    }
    // CraftBukkit end
}
项目:Almura-Server    文件:CraftWorld.java   
public void setStorm(boolean hasStorm) {
    CraftServer server = world.getServer();

    WeatherChangeEvent weather = new WeatherChangeEvent(this, hasStorm);
    server.getPluginManager().callEvent(weather);
    if (!weather.isCancelled()) {
        world.worldData.setStorm(hasStorm);

        // These numbers are from Minecraft
        if (hasStorm) {
            setWeatherDuration(rand.nextInt(12000) + 12000);
        } else {
            setWeatherDuration(rand.nextInt(168000) + 12000);
        }
    }
}
项目:Almura-Server    文件:WorldServer.java   
private void Z() {
    // CraftBukkit start
    WeatherChangeEvent weather = new WeatherChangeEvent(this.getWorld(), false);
    this.getServer().getPluginManager().callEvent(weather);

    ThunderChangeEvent thunder = new ThunderChangeEvent(this.getWorld(), false);
    this.getServer().getPluginManager().callEvent(thunder);
    if (!weather.isCancelled()) {
        this.worldData.setWeatherDuration(0);
        this.worldData.setStorm(false);
    }
    if (!thunder.isCancelled()) {
        this.worldData.setThunderDuration(0);
        this.worldData.setThundering(false);
    }
    // CraftBukkit end
}
项目:Tweakkit-Server    文件:CraftWorld.java   
public void setStorm(boolean hasStorm) {
    CraftServer server = world.getServer();

    WeatherChangeEvent weather = new WeatherChangeEvent(this, hasStorm);
    server.getPluginManager().callEvent(weather);
    if (!weather.isCancelled()) {
        world.worldData.setStorm(hasStorm);

        // These numbers are from Minecraft
        if (hasStorm) {
            setWeatherDuration(rand.nextInt(12000) + 12000);
        } else {
            setWeatherDuration(rand.nextInt(168000) + 12000);
        }
    }
}
项目:Tweakkit-Server    文件:WorldServer.java   
private void Y() {
    // CraftBukkit start
    WeatherChangeEvent weather = new WeatherChangeEvent(this.getWorld(), false);
    this.getServer().getPluginManager().callEvent(weather);

    ThunderChangeEvent thunder = new ThunderChangeEvent(this.getWorld(), false);
    this.getServer().getPluginManager().callEvent(thunder);
    if (!weather.isCancelled()) {
        this.worldData.setWeatherDuration(0);
        this.worldData.setStorm(false);
    }
    if (!thunder.isCancelled()) {
        this.worldData.setThunderDuration(0);
        this.worldData.setThundering(false);
    }
    // CraftBukkit end
}
项目:Cauldron    文件:WorldServer.java   
private void resetRainAndThunder()
{
    // CraftBukkit start
    WeatherChangeEvent weather = new WeatherChangeEvent(this.getWorld(), false);
    this.getServer().getPluginManager().callEvent(weather);
    ThunderChangeEvent thunder = new ThunderChangeEvent(this.getWorld(), false);
    this.getServer().getPluginManager().callEvent(thunder);

    if (!weather.isCancelled())
    {
        this.worldInfo.setRainTime(0);
        this.worldInfo.setRaining(false);
    }

    if (!thunder.isCancelled())
    {
        this.worldInfo.setThunderTime(0);
        this.worldInfo.setThundering(false);
    }

    // CraftBukkit end
    if (!weather.isCancelled() && !thunder.isCancelled()) provider.resetRainAndThunder(); // Cauldron
}
项目:Cauldron    文件:CraftWorld.java   
public void setStorm(boolean hasStorm) {
    CraftServer server = world.getServer();

    WeatherChangeEvent weather = new WeatherChangeEvent(this, hasStorm);
    server.getPluginManager().callEvent(weather);
    if (!weather.isCancelled()) {
        world.worldInfo.setRaining(hasStorm);

        // These numbers are from Minecraft
        if (hasStorm) {
            setWeatherDuration(rand.nextInt(12000) + 12000);
        } else {
            setWeatherDuration(rand.nextInt(168000) + 12000);
        }
    }
}
项目:TatsuCraftMod    文件:TFM_WeatherListener.java   
@EventHandler(priority = EventPriority.HIGH)
public void onWeatherChange(WeatherChangeEvent event)
{
    try
    {
        if (event.getWorld() == TFM_AdminWorld.getInstance().getWorld() && TFM_AdminWorld.getInstance().getWeatherMode() != TFM_AdminWorld.WeatherMode.OFF)
        {
            return;
        }
    }
    catch (Exception ex)
    {
    }

    if (event.toWeatherState() && TFM_ConfigEntry.DISABLE_WEATHER.getBoolean())
    {
        event.setCancelled(true);
        return;
    }
}
项目:greenhouses    文件:Ecosystem.java   
@EventHandler
public void onWeatherChangeEvent(final WeatherChangeEvent e) {
    if (!Settings.worldName.contains(e.getWorld().getName())) {
        return;
    }
    if (e.toWeatherState()) {
        // It's raining
        plugin.logger(3,"It's raining!");
        startSnow();
    } else {
        // It's stopped raining!
        plugin.logger(3,"Stopped raining!");
        if (snow != null)
            snow.cancel();
    }
}
项目:Craft-city    文件:CraftWorld.java   
public void setStorm(boolean hasStorm) {
    CraftServer server = world.getServer();

    WeatherChangeEvent weather = new WeatherChangeEvent(this, hasStorm);
    server.getPluginManager().callEvent(weather);
    if (!weather.isCancelled()) {
        world.worldData.setStorm(hasStorm);

        // These numbers are from Minecraft
        if (hasStorm) {
            setWeatherDuration(rand.nextInt(12000) + 12000);
        } else {
            setWeatherDuration(rand.nextInt(168000) + 12000);
        }
    }
}
项目:Craft-city    文件:WorldServer.java   
private void X() {
    // CraftBukkit start
    WeatherChangeEvent weather = new WeatherChangeEvent(this.getWorld(), false);
    this.getServer().getPluginManager().callEvent(weather);

    ThunderChangeEvent thunder = new ThunderChangeEvent(this.getWorld(), false);
    this.getServer().getPluginManager().callEvent(thunder);
    if (!weather.isCancelled()) {
        this.worldData.setWeatherDuration(0);
        this.worldData.setStorm(false);
    }
    if (!thunder.isCancelled()) {
        this.worldData.setThunderDuration(0);
        this.worldData.setThundering(false);
    }
    // CraftBukkit end
}
项目:MCPBukkit    文件:CraftWorld.java   
public void setStorm(boolean hasStorm) {
    CraftServer server = world.getServer();

    WeatherChangeEvent weather = new WeatherChangeEvent((org.bukkit.World) this, hasStorm);
    server.getPluginManager().callEvent(weather);
    if (!weather.isCancelled()) {
        world.field_72986_A.func_76084_b(hasStorm);

        // These numbers are from Minecraft
        if (hasStorm) {
            setWeatherDuration(rand.nextInt(12000) + 12000);
        } else {
            setWeatherDuration(rand.nextInt(168000) + 12000);
        }
    }
}
项目:UltraCore    文件:Events.java   
@EventHandler(priority=EventPriority.HIGHEST)
public void onWeatherChange(WeatherChangeEvent event) {

  if (plugin.getConfig().getString("toggle.noweather").equals(true)) {
    boolean rain = event.toWeatherState();
    if(rain)
        event.setCancelled(true);
    }
}
项目:UltraCore    文件:Events.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onWeatherChange(WeatherChangeEvent event) {

    if (plugin.getConfig().getString("toggle.noweather").equals(true)) {
        boolean rain = event.toWeatherState();
        if (rain)
            event.setCancelled(true);
    }
}
项目:ZentrelaRPG    文件:EnvironmentManager.java   
@EventHandler
public void onWeatherChange(WeatherChangeEvent event) {
    event.getWorld().setThunderDuration(0);
    event.getWorld().setWeatherDuration(0);
    event.getWorld().setThundering(false);
    event.setCancelled(true);
}
项目:SkyWarsReloaded    文件:LobbyListener.java   
@EventHandler
public void onWeatherChange(WeatherChangeEvent e) {
    if (SkyWarsReloaded.getCfg().weatherDisabled()) {
        Location spawn = SkyWarsReloaded.getCfg().getSpawn();
        if (spawn != null) {
            if (spawn.getWorld().equals(e.getWorld())) {
                e.setCancelled(true);
            } 
        }
    }
}
项目:UltimateSpawn    文件:BasicFeatures.java   
@EventHandler
public void WeatherDisable(WeatherChangeEvent e) {
    if (ConfigGServerEvent.getConfig().getBoolean("Server.Disable.Weather.Enable")) {
        if (!ConfigGServerEvent.getConfig().getBoolean("Server.Disable.Weather.World.All_World")) {
            if (WorldUtils.getWW().contains(e.getWorld().getName())) {
                e.setCancelled(true);
            }
        } else {
            e.setCancelled(true);
        }
    }
}
项目:ZorahPractice    文件:EnvironmentListener.java   
@EventHandler(priority= EventPriority.HIGHEST)
public void onWeatherChange(WeatherChangeEvent event) {
    boolean rain = event.toWeatherState();

    if (rain) {
        event.setCancelled(true);
    }
}
项目:BloodMoon    文件:WeatherListener.java   
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onWeatherChange(WeatherChangeEvent event) {
    World world = event.getWorld();

    if (plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.WEATHER)) {
        event.setCancelled(true);
    }
}
项目:CanaryBukkit    文件:CanaryWorldListener.java   
@HookHandler(priority = Priority.CRITICAL, ignoreCanceled = true)
public void onWeatherChange(final WeatherChangeHook hook) {
    WeatherChangeEvent event = new WeatherChangeEvent(new CanaryWorld(hook.getWorld()), hook.turningOn());
    event.setCancelled(hook.isCanceled());
    server.getPluginManager().callEvent(event);
    if (event.isCancelled()) {
        hook.setCanceled();
    }
}
项目:libelula    文件:GameManager.java   
public void ajustWeather(WeatherChangeEvent e) {
    Game game = worldGame.get(e.getWorld());
    if (game != null) {
        if (game.mapData.weather.fixed) {
            if (e.toWeatherState() != game.mapData.weather.storm) {
                e.getWorld().setStorm(game.mapData.weather.storm);
            }
        }
    }
}
项目:libelula    文件:GameManager.java   
public void ajustWeather(WeatherChangeEvent e) {
    Game game = worldGame.get(e.getWorld());
    if (game != null) {
        if (game.mapData.weather.fixed) {
            if (e.toWeatherState() != game.mapData.weather.storm) {
                e.getWorld().setStorm(game.mapData.weather.storm);
            }
        }
    }
}
项目:SurvivalGamesX    文件:BlockListener.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onWeatherChange(WeatherChangeEvent ev) {
    boolean changeToStorm = ev.toWeatherState();
    if(changeToStorm && !plugin.getArenaManager().getCurrentArena().stormy
            || !changeToStorm && plugin.getArenaManager().getCurrentArena().stormy)
        ev.setCancelled(true);
    ev.getWorld().setThundering(false);
}
项目:acidisland    文件:AcidEffect.java   
/**
 * Tracks weather changes and acid rain
 * 
 * @param e
 */
@EventHandler(priority = EventPriority.NORMAL)
public void onWeatherChange(final WeatherChangeEvent e) {
    if (DEBUG)
        plugin.getLogger().info("DEBUG: " + e.getEventName());

    // Check that they are in the ASkyBlock world
    // plugin.getLogger().info("weather change noted");
    if (!e.getWorld().getName().equalsIgnoreCase(Settings.worldName)) {
        return;
    }
    this.isRaining = e.toWeatherState();
    // plugin.getLogger().info("is raining = " + isRaining);
}
项目:UltimateSurvivalGames    文件:PlayerListener.java   
@EventHandler
public void onWeatherChange(WeatherChangeEvent event) {
    for(Game game : SurvivalGames.gameManager.getGames()) {
        for(Arena arena : game.getArenas()) {
            if(event.getWorld().equals(arena.getMinimumLocation().getWorld()) && event.toWeatherState()) {
                event.setCancelled(true);
            }
        }
    }
}
项目:askyblock    文件:AcidEffect.java   
/**
 * Tracks weather changes and acid rain
 * 
 * @param e
 */
@EventHandler(priority = EventPriority.NORMAL)
public void onWeatherChange(final WeatherChangeEvent e) {
    if (DEBUG)
        plugin.getLogger().info("DEBUG: " + e.getEventName());

    // Check that they are in the ASkyBlock world
    // plugin.getLogger().info("weather change noted");
    if (!e.getWorld().getName().equalsIgnoreCase(Settings.worldName)) {
        return;
    }
    this.isRaining = e.toWeatherState();
    // plugin.getLogger().info("is raining = " + isRaining);
}
项目:rftd    文件:WeatherListener.java   
@EventHandler
public void onWeatherChange(WeatherChangeEvent e) {
    if(e.toWeatherState()) {
        e.setCancelled(true);
        World world = e.getWorld();
        world.setStorm(false);
        world.setThundering(false);
        world.setWeatherDuration(100000);
    }
}
项目:CraftoPlugin    文件:WeatherComponent.java   
@EventHandler
public void onWeatherChange(final WeatherChangeEvent event) {
    if (event.toWeatherState()) { // True if weather is being set to 'raining'
        CraftoScheduler.runTaskLater(this.module, TickDuration.ofSeconds(1), () -> {
            final World world = Utility.getMainWorld();

            world.setWeatherDuration(WeatherComponent.MAX_BAD_WEATHER_DURATION);
            if (world.isThundering()) { world.setThunderDuration(WeatherComponent.MAX_BAD_WEATHER_DURATION); }
        });
    }
}