Search in sources :

Example 1 with WeatherUniverse

use of org.lanternpowered.api.world.weather.WeatherUniverse in project LanternServer by LanternPowered.

the class CommandToggleDownfall method completeSpec.

@Override
public void completeSpec(PluginContainer pluginContainer, CommandSpec.Builder specBuilder) {
    specBuilder.arguments(GenericArguments.flags().valueFlag(GenericArguments.world(CommandHelper.WORLD_KEY), "-world", "w").buildWith(GenericArguments.none())).executor((src, args) -> {
        final LanternWorldProperties world = CommandHelper.getWorldProperties(src, args);
        final WeatherUniverse weatherUniverse = world.getWorld().get().getWeatherUniverse().orElse(null);
        final LanternWeather weather = (LanternWeather) weatherUniverse.getWeather();
        if (weather.getOptions().getOrDefault(WeatherOptions.RAIN_STRENGTH).get() > 0) {
            weatherUniverse.setWeather(Weathers.CLEAR);
        } else {
            weatherUniverse.setWeather(Weathers.RAIN);
        }
        return CommandResult.success();
    });
}
Also used : LanternWeather(org.lanternpowered.server.world.weather.LanternWeather) WeatherUniverse(org.lanternpowered.api.world.weather.WeatherUniverse) LanternWorldProperties(org.lanternpowered.server.world.LanternWorldProperties)

Aggregations

WeatherUniverse (org.lanternpowered.api.world.weather.WeatherUniverse)1 LanternWorldProperties (org.lanternpowered.server.world.LanternWorldProperties)1 LanternWeather (org.lanternpowered.server.world.weather.LanternWeather)1