@Override public void setWeather(WeatherType weatherType) { if (weatherType == WeatherTypes.THUNDER_STORM) { getWorld().setThundering(true); } else if (weatherType == WeatherTypes.RAIN) { getWorld().setStorm(true); } else { getWorld().setStorm(false); getWorld().setThundering(false); } }
@Override public boolean execute(CommandSender sender, String currentAlias, String[] args) { if (!testPermission(sender)) return true; if (args.length == 0) { sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); return false; } int duration = (300 + new Random().nextInt(600)) * 20; if (args.length >= 2) { duration = getInteger(sender, args[1], 1, 1000000) * 20; } World world = Bukkit.getWorlds().get(0); world.setWeatherDuration(duration); world.setThunderDuration(duration); if ("clear".equalsIgnoreCase(args[0])) { world.setStorm(false); world.setThundering(false); Command.broadcastCommandMessage(sender, "Changed weather to clear for " + (duration / 20) + " seconds."); } else if ("rain".equalsIgnoreCase(args[0])) { world.setStorm(true); world.setThundering(false); Command.broadcastCommandMessage(sender, "Changed weather to rainy for " + (duration / 20) + " seconds."); } else if ("thunder".equalsIgnoreCase(args[0])) { world.setStorm(true); world.setThundering(true); Command.broadcastCommandMessage(sender, "Changed weather to thundering " + (duration / 20) + " seconds."); } return true; }
@Override public void setWeather(WeatherType weatherType, long duration) { // Who named these methods... if (weatherType == WeatherTypes.THUNDER_STORM) { getWorld().setThundering(true); getWorld().setThunderDuration((int) duration); getWorld().setWeatherDuration((int) duration); } else if (weatherType == WeatherTypes.RAIN) { getWorld().setStorm(true); getWorld().setWeatherDuration((int) duration); } else { getWorld().setStorm(false); getWorld().setThundering(false); getWorld().setWeatherDuration((int) duration); } }
@Override public boolean execute(CommandSender sender, String label, String[] args, CommandMessages commandMessages) { if (!testPermission(sender, commandMessages.getPermissionMessage())) { return true; } final World world = CommandUtils.getWorld(sender); world.setThundering(!world.hasStorm()); world.setStorm(!world.hasStorm()); new LocalizedStringImpl("toggledownfall.done", commandMessages.getResourceBundle()) .send(sender); return true; }
@Override public void setThundering(boolean b) { w.setThundering(b); }
@Override public SpellResult perform(CastContext context) { World world = context.getWorld(); if (world == null) { return SpellResult.WORLD_REQUIRED; } boolean hasStorm = world.hasStorm(); boolean makeStorm = weatherString.equals("storm"); if (weatherString.equals("cycle")) { makeStorm = !hasStorm; } if (makeStorm) { world.setStorm(true); world.setThundering(true); } else { world.setStorm(false); world.setThundering(false); } return makeStorm ? SpellResult.CAST : SpellResult.ALTERNATE; }
@Override public void run(String playerID) { World world = PlayerConverter.getPlayer(playerID).getWorld(); world.setStorm(storm); world.setThundering(thunder); }
public void setWorldToWeather(World world) { world.setStorm(this == RAIN || this == STORM); world.setWeatherDuration(this == RAIN || this == STORM ? 20 * 60 * 5 : 0); world.setThundering(this == STORM); world.setThunderDuration(this == STORM ? 20 * 60 * 5 : 0); }
@Override public Boolean validateChange(String property, Boolean newValue, Boolean oldValue, MVWorld object) throws ChangeDeniedException { if (!newValue) { final World world = getCBWorld(); if (world != null) { world.setStorm(false); world.setThundering(false); } } return super.validateChange(property, newValue, oldValue, object); } }
@Override public boolean execute(CommandSender sender, String currentAlias, String[] args) { if (!testPermission(sender)) return true; if (args.length == 0) { sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); return false; } int duration = (300 + new Random().nextInt(600)) * 20; if (args.length >= 2) { duration = getInteger(sender, args[1], 1, 1000000) * 20; } World world = Bukkit.getWorlds().get(0); world.setWeatherDuration(duration); world.setThunderDuration(duration); if ("clear".equalsIgnoreCase(args[0])) { world.setStorm(false); world.setThundering(false); Command.broadcastCommandMessage(sender, "Changed weather to clear for " + (duration / 20) + " seconds."); } else if ("rain".equalsIgnoreCase(args[0])) { world.setStorm(true); world.setThundering(false); Command.broadcastCommandMessage(sender, "Changed weather to rainy for " + (duration / 20) + " seconds."); } else if ("thunder".equalsIgnoreCase(args[0])) { world.setStorm(true); world.setThundering(true); Command.broadcastCommandMessage(sender, "Changed weather to thundering " + (duration / 20) + " seconds."); } return true; }
/** * @param rules sets up the time and weather to match the rules */ public void setWeather(GameRuleProvider rules) { if (world == null) { return; } if (rules.isThundering() != null) { if (rules.isThundering()) { world.setThundering(true); world.setStorm(true); world.setThunderDuration(Integer.MAX_VALUE); } else { world.setThundering(false); world.setStorm(false); } } if (rules.getTime() != null) { world.setTime(rules.getTime()); } }
@Override public SpellResult onCast(ConfigurationSection parameters) { World world = getWorld(); boolean hasStorm = world.hasStorm(); if (hasStorm) { world.setStorm(false); world.setThundering(false); /* boolean hasThunder = world.isThundering(); if (hasThunder) { } else { world.setThundering(true); castMessage("You anger the storm"); } */ } else { world.setStorm(true); // This is mainly so we can have different cast messages and effects, but is a bit of a hack. return SpellResult.ALTERNATE; } return SpellResult.CAST; }
@Override protected void onStart() { flatlands.getWorld(); adminworld.getWorld(); // Disable weather if (ConfigEntry.DISABLE_WEATHER.getBoolean()) { for (World world : server.getWorlds()) { world.setThundering(false); world.setStorm(false); world.setThunderDuration(0); world.setWeatherDuration(0); } } }
/** * Initialize the settings for the specified world * @see WorldConfiguration#alwaysRaining * @see WorldConfiguration#disableWeather * @see WorldConfiguration#alwaysThundering * @see WorldConfiguration#disableThunder * @param world The specified world */ public void initWorld(World world) { ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager(); WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(world)); if (wcfg.alwaysRaining && !wcfg.disableWeather) { world.setStorm(true); } else if (wcfg.disableWeather && !wcfg.alwaysRaining) { world.setStorm(false); } if (wcfg.alwaysThundering && !wcfg.disableThunder) { world.setThundering(true); } else if (wcfg.disableThunder && !wcfg.alwaysThundering) { world.setStorm(false); } } }
/** * Periodically create storms based on the current temperature */ @Override public void run() { for (World world : Bukkit.getWorlds()) { //Storm: WorldClimateEngine worldEngine = ClimateEngine.getInstance().getClimateEngine(world.getUID()); if (isAllowed(worldEngine, WeatherData.STORM)) { world.setStorm(true); int duration = (int) weatherDistribution.get(WeatherData.DURATION).getValue(worldEngine.getTemperature()); world.setWeatherDuration(duration); } //Thunder (if storming): if (world.hasStorm() && isAllowed(worldEngine, WeatherData.THUNDER)) { world.setThundering(true); int duration = (int) weatherDistribution.get(WeatherData.DURATION).getValue(worldEngine.getTemperature()); world.setThunderDuration(duration); } //Lightning strike (if storming): // - Random player selected (must be outdoors) if (world.hasStorm() && isAllowed(worldEngine, WeatherData.STRIKE_PLAYER)) { Location location = getOutdoorPlayerLocation(world); if (location != null) { world.strikeLightning(location); } } } }
world.setThundering(true); world.setThundering(false);
if (weatherString.equals("storm")) { world.setStorm(true); world.setThundering(true); } else { world.setStorm(false); world.setThundering(false);