本文整理汇总了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));
}
}
示例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);
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例6: isThundering
@Override
public boolean isThundering() {
final Weather weather = this.weatherData.getWeather();
return weather == Weathers.THUNDER_STORM;
}
示例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();
}
}