From 51e1afefba7dfe27d6f67f74f018c17b2a5ae0ca Mon Sep 17 00:00:00 2001 From: Yazawazi <47273265+Yazawazi@users.noreply.github.com> Date: Wed, 20 Apr 2022 17:16:21 +0800 Subject: [PATCH] Add /weather Command --- .../grasscutter/commands/PlayerCommands.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/main/java/emu/grasscutter/commands/PlayerCommands.java b/src/main/java/emu/grasscutter/commands/PlayerCommands.java index 779e91ef9..656f85a20 100644 --- a/src/main/java/emu/grasscutter/commands/PlayerCommands.java +++ b/src/main/java/emu/grasscutter/commands/PlayerCommands.java @@ -16,10 +16,12 @@ import emu.grasscutter.game.entity.EntityMonster; import emu.grasscutter.game.inventory.GenshinItem; import emu.grasscutter.game.inventory.Inventory; import emu.grasscutter.game.inventory.ItemType; +import emu.grasscutter.game.props.ClimateType; import emu.grasscutter.game.props.ActionReason; import emu.grasscutter.game.props.FightProperty; import emu.grasscutter.game.props.PlayerProperty; import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify; +import emu.grasscutter.server.packet.send.PacketSceneAreaWeatherNotify; import emu.grasscutter.server.packet.send.PacketItemAddHintNotify; import emu.grasscutter.utils.Position; @@ -536,4 +538,29 @@ public final class PlayerCommands { } } } + + @Command(label = "weather", aliases = {"weather", "w"}, + usage = "weather ", description = "Changes the weather.", + execution = Command.Execution.PLAYER, permission = "player.weather" + ) + public static class ChangeWeatherCommand implements CommandHandler { + @Override + public void execute(GenshinPlayer player, List args) { + if (args.size() < 1) { + CommandHandler.sendMessage(player, "Usage: weather "); + return; + } + + try { + int weatherId = Integer.parseInt(args.get(0)); + + ClimateType climate = ClimateType.getTypeByValue(weatherId); + + player.getScene().setClimate(climate); + player.getScene().broadcastPacket(new PacketSceneAreaWeatherNotify(player)); + } catch (NumberFormatException ignored) { + CommandHandler.sendMessage(player, "Invalid weather ID."); + } + } + } }