本文整理汇总了Java中org.spongepowered.api.world.weather.Weathers类的典型用法代码示例。如果您正苦于以下问题:Java Weathers类的具体用法?Java Weathers怎么用?Java Weathers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Weathers类属于org.spongepowered.api.world.weather包,在下文中一共展示了Weathers类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setWeathers
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@Inject(method = "registerDefaults", at = @At("RETURN"), remap = false)
private void setWeathers(CallbackInfo ci) {
// The weathers
this.weathers = Maps.newHashMap();
// Sponge has only a lookup by the name of the weather,
// we will also add the by identifier
for (Weather weather : this.weatherMappings.values()) {
this.weathers.put(weather.getId().toLowerCase(), (WeatherType) weather);
this.weathers.put(weather.getName().toLowerCase(), (WeatherType) weather);
}
// Add some default aliases and command messages
((IMixinWeather) Weathers.THUNDER_STORM).setAliases(Lists.newArrayList("storm", "thunder"));
((IMixinWeather) Weathers.THUNDER_STORM).setCommandMessage("commands.weather.thunder");
((IMixinWeather) Weathers.THUNDER_STORM).setRainStrength(1f);
((IMixinWeather) Weathers.THUNDER_STORM).setDarkness(1f);
// The rate is the chance for every chunk, every tick
((IMixinWeather) Weathers.THUNDER_STORM).setLightningRate(0.00001f);
((IMixinWeather) Weathers.THUNDER_STORM).setThunderRate(1f);
((IMixinWeather) Weathers.CLEAR).setAliases(Lists.newArrayList("sunny"));
((IMixinWeather) Weathers.CLEAR).setCommandMessage("commands.weather.clear");
((IMixinWeather) Weathers.RAIN).setAliases(Lists.newArrayList("rainy"));
((IMixinWeather) Weathers.RAIN).setCommandMessage("commands.weather.rain");
((IMixinWeather) Weathers.RAIN).setRainStrength(1f);
this.addAliases(Weathers.THUNDER_STORM);
this.addAliases(Weathers.CLEAR);
}
开发者ID:Cybermaxke,项目名称:Weathers,代码行数:27,代码来源:MixinWeatherRegistryModule.java
示例2: cast
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@Override
public SkillResult cast(IActiveCharacter character, ExtendedSkillInfo info, SkillModifier modifier) {
Player character1 = character.getEntity();
if (character1.getWorld().getWeather() == Weathers.CLEAR) {
Vector3d position = character1.getLocation().getPosition();
if (character1.getWorld().getHighestYAt(position.getFloorX(), position.getFloorZ()) > position.getFloorY()) {
character1.sendMessage(ChatTypes.ACTION_BAR, Text.builder(SkillLocalization.ASTRONOMY_CANNOT_SEE_THE_SKY)
.color(TextColors.RED).build());
return SkillResult.CANCELLED;
}
ItemStack is = Utils.createTeleportationScroll(character.getLocation());
character.getEntity().getInventory().offer(is);
return SkillResult.OK;
}
character1.sendMessage(ChatTypes.ACTION_BAR, Text.builder(SkillLocalization.ASTRONOMY_CANNOT_SEE_THE_SKY)
.color(TextColors.RED).build());
return SkillResult.CANCELLED;
}
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:20,代码来源:Astronomy.java
示例3: aquireSpec
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
public static CommandSpec aquireSpec() {
Map<String, Weather> map = new HashMap<>();
map.put("clear", Weathers.CLEAR);
map.put("rain", Weathers.RAIN);
map.put("thunder", Weathers.THUNDER_STORM);
return CommandSpec.builder()
.description(Text.of("Change the weather"))
.permission("skree.weathercommand")
.arguments(
seq(
onlyOne(choices(Text.of("type"), map)),
// TODO should be onlyOne(catalogedElement(Text.of("type"), game, Weather.class)),
onlyOne(optionalWeak(integer(Text.of("duration")))),
onlyOne(optional(world(Text.of("world"))))
)
)
.executor(new WeatherCommand()).build();
}
开发者ID:Skelril,项目名称:Skree,代码行数:21,代码来源:WeatherCommand.java
示例4: parseValue
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@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,代码行数:22,代码来源:WeatherArgument.java
示例5: getWeather
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
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,代码行数:12,代码来源:EEWeather.java
示例6: getMessage
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
private EMessageSender getMessage(final Weather weather) {
if (weather.equals(Weathers.RAIN)) {
return EEMessages.WEATHER_RAIN.sender();
} else if (weather.equals(Weathers.THUNDER_STORM)) {
return EEMessages.WEATHER_STORM.sender();
}
return EEMessages.WEATHER_SUN.sender();
}
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:9,代码来源:EEWeather.java
示例7: getMessageDuration
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
private EMessageSender getMessageDuration(final Weather weather) {
if (weather.equals(Weathers.RAIN)) {
return EEMessages.WEATHER_RAIN_DURATION.sender();
} else if (weather.equals(Weathers.THUNDER_STORM)) {
return EEMessages.WEATHER_STORM_DURATION.sender();
}
return EEMessages.WEATHER_SUN_DURATION.sender();
}
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:10,代码来源:EEWeather.java
示例8: setCleanWeatherTime
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@Overwrite
public void setCleanWeatherTime(int time) {
if (this.world != null) {
if (time > 0) {
this.world.forecast(Weathers.CLEAR, time);
}
} else {
this.cleanWeatherTime = time;
}
}
开发者ID:Cybermaxke,项目名称:Weathers,代码行数:11,代码来源:MixinWorldInfo.java
示例9: setRainTime
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@Overwrite
public void setRainTime(int time) {
if (this.world != null) {
this.raining = time > 0;
if (this.thundering && this.thunderTime > 0 && this.raining) {
this.world.forecast(Weathers.THUNDER_STORM, time);
} else if (this.raining) {
this.world.forecast(Weathers.RAIN, time);
} else {
this.world.forecast(Weathers.CLEAR, this.cleanWeatherTime);
}
} else {
this.rainTime = time;
}
}
开发者ID:Cybermaxke,项目名称:Weathers,代码行数:16,代码来源:MixinWorldInfo.java
示例10: setThunderTime
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@Overwrite
public void setThunderTime(int time) {
if (this.world != null) {
this.thundering = time > 0;
if (this.thundering) {
this.world.forecast(Weathers.THUNDER_STORM, time);
} else if (this.raining && this.rainTime > 0) {
this.world.forecast(Weathers.RAIN, this.rainTime);
} else {
this.world.forecast(Weathers.CLEAR, this.cleanWeatherTime);
}
} else {
this.thunderTime = time;
}
}
开发者ID:Cybermaxke,项目名称:Weathers,代码行数:16,代码来源:MixinWorldInfo.java
示例11: setThundering
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@Overwrite
public void setThundering(boolean flag) {
if (this.world != null) {
if (!flag) {
if (this.raining && this.rainTime > 0) {
this.world.forecast(Weathers.RAIN, this.rainTime);
} else {
this.world.forecast(Weathers.CLEAR, this.cleanWeatherTime);
}
}
} else {
this.raining = flag;
}
}
开发者ID:Cybermaxke,项目名称:Weathers,代码行数:15,代码来源:MixinWorldInfo.java
示例12: setRaining
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@Overwrite
public void setRaining(boolean flag) {
if (this.world != null) {
if (!flag) {
this.world.forecast(Weathers.CLEAR, this.cleanWeatherTime);
}
} else {
this.raining = flag;
}
}
开发者ID:Cybermaxke,项目名称:Weathers,代码行数:11,代码来源:MixinWorldInfo.java
示例13: calculateInitialWeather
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@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,代码行数:28,代码来源:MixinWorld.java
示例14: setRaining
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@Override
public void setRaining(boolean state) {
LanternWeather weather = this.weatherData.getWeather();
final boolean raining = weather.getOptions().getOrDefault(WeatherOptions.RAIN_STRENGTH).get() > 0;
if (raining != state) {
weather = (LanternWeather) (state ? Weathers.RAIN : Weathers.CLEAR);
this.weatherData.setWeather(weather);
this.weatherData.setRemainingDuration(weather.getRandomTicksDuration());
this.weatherData.setRunningDuration(0);
}
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:12,代码来源:LanternWorldProperties.java
示例15: setThundering
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@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,代码行数:12,代码来源:LanternWorldProperties.java
示例16: setThunderTime
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@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,代码行数:9,代码来源:LanternWorldProperties.java
示例17: getWeather
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@Override
public LanternWeather getWeather() {
if (this.weatherUniverse != null) {
return this.weatherUniverse.getWeather();
}
return (LanternWeather) Weathers.CLEAR;
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:8,代码来源:LanternWorld.java
示例18: execute
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException {
checkPermission(sender, WeatherPermissions.UC_WEATHER_WEATHER_SUN);
World world;
if (sender instanceof Locatable) {
world = ((Locatable) sender).getWorld();
} else {
throw new ErrorMessageException(Messages.getFormatted(sender, "core.noplayer"));
}
world.setWeather(Weathers.RAIN);
Messages.send(sender, "weather.command.weather.success", "%weather%", "rain", "%world%", world.getName());
return CommandResult.success();
}
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:14,代码来源:RainCommand.java
示例19: execute
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException {
checkPermission(sender, WeatherPermissions.UC_WEATHER_WEATHER_SUN);
World world;
if (sender instanceof Locatable) {
world = ((Locatable) sender).getWorld();
} else {
throw new ErrorMessageException(Messages.getFormatted(sender, "core.noplayer"));
}
world.setWeather(Weathers.CLEAR);
Messages.send(sender, "weather.command.weather.success", "%weather%", "sun", "%world%", world.getName());
return CommandResult.success();
}
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:14,代码来源:SunCommand.java
示例20: execute
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException {
checkPermission(sender, WeatherPermissions.UC_WEATHER_WEATHER_SUN);
World world;
if (sender instanceof Locatable) {
world = ((Locatable) sender).getWorld();
} else {
throw new ErrorMessageException(Messages.getFormatted(sender, "core.noplayer"));
}
world.setWeather(Weathers.THUNDER_STORM);
Messages.send(sender, "weather.command.weather.success", "%weather%", "thunder", "%world%", world.getName());
return CommandResult.success();
}
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:14,代码来源:ThunderCommand.java
注:本文中的org.spongepowered.api.world.weather.Weathers类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论