当前位置: 首页>>代码示例>>Java>>正文


Java Weathers.THUNDER_STORM属性代码示例

本文整理汇总了Java中org.spongepowered.api.world.weather.Weathers.THUNDER_STORM属性的典型用法代码示例。如果您正苦于以下问题:Java Weathers.THUNDER_STORM属性的具体用法?Java Weathers.THUNDER_STORM怎么用?Java Weathers.THUNDER_STORM使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.spongepowered.api.world.weather.Weathers的用法示例。


在下文中一共展示了Weathers.THUNDER_STORM属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseValue

@Nullable
@Override
public Weather parseValue(CommandSource source, CommandArgs args) throws ArgumentParseException {
    String value = args.next();
    switch (value) {
        case "sun":
        case "clear":
            return Weathers.CLEAR;
        case "rain":
        case "snow":
        case "downfall":
            return Weathers.RAIN;
        case "thunder":
        case "thunderstorm":
        case "thunder_storm":
        case "storm":
            return Weathers.THUNDER_STORM;
        default:
            throw args.createError(Messages.getFormatted(source, "weather.command.weather.invalidweathertype", "%weather%", value));
    }
}
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:21,代码来源:WeatherArgument.java

示例2: getWeather

private Optional<Weather> getWeather(final String weather_name) {
	Weather weather = null;
	if (weather_name.equalsIgnoreCase("sun")) {
		weather = Weathers.CLEAR;
	} else if (weather_name.equalsIgnoreCase("rain")) {
		weather = Weathers.RAIN;
	} else if (weather_name.equalsIgnoreCase("storm")) {
		weather = Weathers.THUNDER_STORM;
	}
	return Optional.ofNullable(weather);
}
 
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:11,代码来源:EEWeather.java

示例3: calculateInitialWeather

@Overwrite
protected void calculateInitialWeather() {
    final IMixinWorldInfo info = (IMixinWorldInfo) this.worldInfo;
    info.setWorld(this);
    if (info.getWeather() == null) {
        final Weather weather;
        int duration;
        int rainTime = this.worldInfo.raining ? this.worldInfo.getRainTime() : 0;
        int thunderTime = this.worldInfo.thundering ? this.worldInfo.thunderTime : 0;
        this.worldInfo.thunderTime = thunderTime;
        this.worldInfo.rainTime = rainTime;
        if (rainTime <= 0) {
            weather = Weathers.CLEAR;
            duration = this.worldInfo.getCleanWeatherTime();
        } else if (thunderTime > 0) {
            weather = Weathers.THUNDER_STORM;
            duration = Math.min(rainTime, thunderTime);
        } else {
            weather = Weathers.RAIN;
            duration = rainTime;
        }
        info.setWeather((WeatherType) weather);
        info.setWeatherDuration(duration);
        info.setElapsedWeatherDuration(0);
    }
    this.initWeatherVolume();
}
 
开发者ID:Cybermaxke,项目名称:Weathers,代码行数:27,代码来源:MixinWorld.java

示例4: setThundering

@Override
public void setThundering(boolean state) {
    LanternWeather weather = this.weatherData.getWeather();
    final boolean thunderStorm = weather == Weathers.THUNDER_STORM;
    if (thunderStorm != state) {
        weather = (LanternWeather) (state ? Weathers.THUNDER_STORM : Weathers.CLEAR);
        this.weatherData.setWeather(weather);
        this.weatherData.setRemainingDuration(weather.getRandomTicksDuration());
        this.weatherData.setRunningDuration(0);
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:11,代码来源:LanternWorldProperties.java

示例5: setThunderTime

@Override
public void setThunderTime(int time) {
    final Weather weather = this.weatherData.getWeather();
    final boolean thunderStorm = weather == Weathers.THUNDER_STORM;
    if (thunderStorm) {
        this.weatherData.setRemainingDuration(time);
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:8,代码来源:LanternWorldProperties.java

示例6: isThundering

@Override
public boolean isThundering() {
    final Weather weather = this.weatherData.getWeather();
    return weather == Weathers.THUNDER_STORM;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:LanternWorldProperties.java

示例7: execute

public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException
{
	String weatherString = ctx.<String> getOne("weather").get();
	Optional<Integer> duration = ctx.<Integer> getOne("duration");

	if (src instanceof Player)
	{
		Player player = (Player) src;

		Weather weather;

		if (weatherString.toLowerCase().equals("clear") || weatherString.toLowerCase().equals("sun"))
		{
			weather = Weathers.CLEAR;
			player.sendMessage(Text.of(TextColors.GOLD, "Changing weather to ", TextColors.GRAY, "sunny."));
		}
		else if (weatherString.toLowerCase().equals("rain"))
		{
			weather = Weathers.RAIN;
			player.sendMessage(Text.of(TextColors.GOLD, "Changing weather to ", TextColors.GRAY, "rain."));
		}
		else if (weatherString.toLowerCase().equals("storm") || weatherString.toLowerCase().equals("thunderstorm"))
		{
			weather = Weathers.THUNDER_STORM;
			player.sendMessage(Text.of(TextColors.GOLD, "Changing weather to ", TextColors.GRAY, "storm."));
		}
		else
		{
			src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "Input invalid: " + weatherString));
			return CommandResult.success();
		}

		if (duration.isPresent())
		{
			player.getWorld().setWeather(weather, duration.get());
		}
		else
		{
			player.getWorld().setWeather(weather);
		}
		return CommandResult.success();
	}
	else
	{
		src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You must be a in-game player to do /weather!"));
		return CommandResult.success();
	}
}
 
开发者ID:hsyyid,项目名称:EssentialCmds,代码行数:48,代码来源:WeatherExecutor.java


注:本文中的org.spongepowered.api.world.weather.Weathers.THUNDER_STORM属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。