package emu.grasscutter.command.commands; import emu.grasscutter.Grasscutter; import emu.grasscutter.command.Command; import emu.grasscutter.command.CommandHandler; import emu.grasscutter.game.player.Player; import emu.grasscutter.game.props.ClimateType; import emu.grasscutter.server.packet.send.PacketSceneAreaWeatherNotify; import java.util.List; @Command(label = "weather", usage = "weather [climateId]", description = "Changes the weather.", aliases = {"w"}, permission = "player.weather") public final class WeatherCommand implements CommandHandler { @Override public void execute(Player sender, Player targetPlayer, List args) { if (targetPlayer == null) { CommandHandler.sendMessage(sender, translate("commands.execution.need_target")); return; } int weatherId = 0; int climateId = 1; switch (args.size()) { case 2: try { climateId = Integer.parseInt(args.get(1)); } catch (NumberFormatException ignored) { CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Weather_invalid_id); } case 1: try { weatherId = Integer.parseInt(args.get(0)); } catch (NumberFormatException ignored) { CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Weather_invalid_id); } break; default: CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Weather_usage); return; } ClimateType climate = ClimateType.getTypeByValue(climateId); targetPlayer.getScene().setWeather(weatherId); targetPlayer.getScene().setClimate(climate); targetPlayer.getScene().broadcastPacket(new PacketSceneAreaWeatherNotify(targetPlayer)); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Weather_message.replace("{weatherId}", Integer.toString(weatherId)).replace("{climateId}", Integer.toString(climateId))); } }