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


Java Weather类代码示例

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


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

示例1: execute

import org.spongepowered.api.world.weather.Weather; //导入依赖的package包/类
@Override
public void execute(CommandQueue queue, CommandEntry entry) {
    WorldTag world = WorldTag.getFor(queue.error, entry.getArgumentObject(queue, 0));
    String weather = entry.getArgumentObject(queue, 1).toString();
    Optional<Weather> type = Sponge.getRegistry().getType(Weather.class, weather);
    if (!type.isPresent()) {
        queue.handleError(entry, "Invalid weather type: '" + weather + "'!");
        return;
    }
    if (entry.arguments.size() > 2) {
        DurationTag duration = DurationTag.getFor(queue.error, entry.getArgumentObject(queue, 2));
        world.getInternal().setWeather(type.get(), (long) (duration.getInternal() * 20));
    }
    else {
        world.getInternal().setWeather(type.get());
    }
    if (queue.shouldShowGood()) {
        queue.outGood("Changed weather to " + ColorSet.emphasis + type.get().getId() + ColorSet.good
                + " in world: " + ColorSet.emphasis + world.debug() + ColorSet.good + "!");
    }
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:22,代码来源:WeatherCommand.java

示例2: applyDetermination

import org.spongepowered.api.world.weather.Weather; //导入依赖的package包/类
@Override
public void applyDetermination(boolean errors, String determination, AbstractTagObject value) {
    if (determination.equals("duration")) {
        DurationTag dt = DurationTag.getFor(this::error, value);
        duration = dt;
        internal.setDuration((int) (dt.getInternal() * 20));
    }
    else if (determination.equals("new_weather")) {
        TextTag tt = TextTag.getFor(this::error, value);
        Optional<Weather> type = Sponge.getRegistry().getType(Weather.class, tt.getInternal());
        if (!type.isPresent()) {
            this.error("Invalid weather type: '" + tt.debug() + "'!");
            return;
        }
        new_weather = new TextTag(Utilities.getIdWithoutDefaultPrefix(type.get().getId()));
        internal.setWeather(type.get());
    }
    else {
        super.applyDetermination(errors, determination, value);
    }
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:22,代码来源:WeatherChangesScriptEvent.java

示例3: commandWeather

import org.spongepowered.api.world.weather.Weather; //导入依赖的package包/类
private CompletableFuture<Boolean> commandWeather(final CommandSource player, final Optional<Weather> weather, final World world) {
	if (!this.plugin.getEverAPI().hasPermissionWorld(player, world)) {
		EAMessages.NO_PERMISSION_WORLD.sender()
			.prefix(EEMessages.PREFIX)
			.replace("{world}", world.getName())
			.sendTo(player);
		return CompletableFuture.completedFuture(false);
	}
	
	if (!world.getProperties().getDimensionType().equals(DimensionTypes.OVERWORLD)) {
		EEMessages.WEATHER_ERROR.sendTo(player);
		return CompletableFuture.completedFuture(false);
	}
	
	if (!weather.isPresent()) {
		player.sendMessage(this.help(player));
		return CompletableFuture.completedFuture(false);
	}
	
	world.setWeather(weather.get());
	this.getMessage(weather.get())
		.replace("{world}", world.getName())
		.replace("{weather}", weather.get().getName())
		.sendTo(player);
	return CompletableFuture.completedFuture(true);
}
 
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:27,代码来源:EEWeather.java

示例4: setWeathers

import org.spongepowered.api.world.weather.Weather; //导入依赖的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

示例5: processCommand

import org.spongepowered.api.world.weather.Weather; //导入依赖的package包/类
@Overwrite
@Override
public void processCommand(ICommandSender sender, String[] args)
        throws WrongUsageException, NumberInvalidException {
    if (args.length < 1 || args.length > 2) {
        throw new WrongUsageException(USAGE);
    }

    final CatalogRegistryModule<Weather> module = SpongeImpl.getGame().getRegistry()
            .getRegistryModuleFor(Weather.class);
    final IMixinWeatherRegistryModule module0 = (IMixinWeatherRegistryModule) module;
    final IMixinWeather weather = (IMixinWeather) module0.findWeather(args[0]);
    if (weather == null) {
        throw new WrongUsageException(USAGE);
    }

    World world = (World) sender.getEntityWorld();
    if (args.length > 1) {
        world.forecast(weather, parseInt(args[1], 1, 1000000) * 20);
    } else {
        world.forecast(weather);
    }

    notifyOperators(sender, this, weather.getCommandMessage());
}
 
开发者ID:Cybermaxke,项目名称:Weathers,代码行数:26,代码来源:MixinCommandWeather.java

示例6: buildAndRegister

import org.spongepowered.api.world.weather.Weather; //导入依赖的package包/类
@Override
public WeatherType buildAndRegister() {
    checkState(this.name != null, "name is not set");
    checkState(this.plugin != null, "plugin is not set");
    final CatalogRegistryModule<Weather> module = SpongeImpl.getGame().getRegistry()
            .getRegistryModuleFor(Weather.class);
    final IMixinWeatherRegistryModule module0 = (IMixinWeatherRegistryModule) module;
    checkState(module0.getWeathers().get(this.name) == null, "name is in use");
    final IMixinWeather weather = (IMixinWeather) new SpongeWeather(this.name);
    weather.setCustomIdentifier(this.plugin.getId().toLowerCase() + ":" + this.name);
    weather.setAliases(this.aliases);
    weather.setDarkness(this.darkness);
    weather.setRainStrength(this.rainStrength);
    weather.setLightningRate(this.lightningRate);
    weather.setThunderRate(this.thunderRate);
    module0.registerAdditionalCatalog(weather);
    return weather;
}
 
开发者ID:Cybermaxke,项目名称:Weathers,代码行数:19,代码来源:SimpleWeatherBuilder.java

示例7: setWeather

import org.spongepowered.api.world.weather.Weather; //导入依赖的package包/类
private boolean setWeather(CauseStack causeStack, Weather weather, long duration, boolean doEvent) {
    checkNotNull(weather, "weather");
    final LanternWeather current = this.weatherData.getWeather();
    if (doEvent) {
        final ChangeWorldWeatherEvent event = SpongeEventFactory.createChangeWorldWeatherEvent(
                causeStack.getCurrentCause(), (int) duration, (int) duration, current, weather, weather, this.world);
        Sponge.getEventManager().post(event);
        if (event.isCancelled()) {
            return true;
        }
        weather = event.getWeather();
        duration = event.getDuration();
    }
    final LanternWeather weather0 = (LanternWeather) weather;
    this.weatherData.setRemainingDuration(duration);
    if (current != weather) {
        this.weatherData.setRunningDuration(0);
        this.weatherData.setWeather(weather0);
    }
    this.darknessTarget = weather0.getOptions().getOrDefault(WeatherOptions.SKY_DARKNESS).get().floatValue();
    this.rainStrengthTarget = weather0.getOptions().getOrDefault(WeatherOptions.RAIN_STRENGTH).get().floatValue();
    return false;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:24,代码来源:LanternWeatherUniverse.java

示例8: aquireSpec

import org.spongepowered.api.world.weather.Weather; //导入依赖的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

示例9: parseValue

import org.spongepowered.api.world.weather.Weather; //导入依赖的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

示例10: getWeather

import org.spongepowered.api.world.weather.Weather; //导入依赖的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

示例11: getMessage

import org.spongepowered.api.world.weather.Weather; //导入依赖的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

示例12: getMessageDuration

import org.spongepowered.api.world.weather.Weather; //导入依赖的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

示例13: onGamePreInitialization

import org.spongepowered.api.world.weather.Weather; //导入依赖的package包/类
@SuppressWarnings({"rawtypes", "unchecked"})
@Listener
public void onGamePreInitialization(GamePreInitializationEvent e) {
    this.logger.info("Loading...");

    // Get the sponge registry
    final SpongeGameRegistry registry = SpongeImpl.getGame().getRegistry();

    // Register the weather builder
    registry.registerBuilderSupplier(WeatherBuilder.class, () -> new SimpleWeatherBuilder());

    // Register the module also for the child type
    final CatalogRegistryModule<Weather> module = registry.getRegistryModuleFor(Weather.class);
    registry.registerModule(WeatherType.class, (CatalogRegistryModule) module);
}
 
开发者ID:Cybermaxke,项目名称:Weathers,代码行数:16,代码来源:WeathersPlugin.java

示例14: registerAdditionalCatalog

import org.spongepowered.api.world.weather.Weather; //导入依赖的package包/类
@Override
public void registerAdditionalCatalog(Weather weatherType) {
    final WeatherType weatherType0 = (WeatherType) checkNotNull(weatherType, "weatherType");
    final String id = weatherType0.getId().toLowerCase();
    checkState(!this.weathers.containsKey(id),
            "identifier is already used: " + weatherType0.getId());
    checkState(!this.weathers.containsKey(weatherType0.getName().toLowerCase()),
            "name is already used: " + weatherType0.getName());
    String name = weatherType.getName().toLowerCase();
    this.weathers.put(id, weatherType0);
    this.weathers.put(name, weatherType0);
    this.weatherAliases.put(id, weatherType0);
    this.weatherAliases.put(name, weatherType0);
    this.addAliases(weatherType0);
}
 
开发者ID:Cybermaxke,项目名称:Weathers,代码行数:16,代码来源:MixinWeatherRegistryModule.java

示例15: addTabCompletionOptions

import org.spongepowered.api.world.weather.Weather; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Overwrite
@Override
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) {
    if (args.length == 1) {
        final CatalogRegistryModule<Weather> module = SpongeImpl.getGame().getRegistry()
                .getRegistryModuleFor(Weather.class);
        final IMixinWeatherRegistryModule module0 = (IMixinWeatherRegistryModule) module;
        return getListOfStringsMatchingLastWord(args, module0.getWeatherAliases().keySet());
    }
    return null;
}
 
开发者ID:Cybermaxke,项目名称:Weathers,代码行数:13,代码来源:MixinCommandWeather.java


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