Skip to content

Commit

Permalink
Add /weather Command
Browse files Browse the repository at this point in the history
  • Loading branch information
Yazawazi committed Apr 20, 2022
1 parent 85801df commit 51e1afe
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/main/java/emu/grasscutter/commands/PlayerCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
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;

Expand Down Expand Up @@ -536,4 +538,29 @@ public void execute(GenshinPlayer player, List<String> args) {
}
}
}

@Command(label = "weather", aliases = {"weather", "w"},
usage = "weather <weather id>", description = "Changes the weather.",
execution = Command.Execution.PLAYER, permission = "player.weather"
)
public static class ChangeWeatherCommand implements CommandHandler {
@Override
public void execute(GenshinPlayer player, List<String> args) {
if (args.size() < 1) {
CommandHandler.sendMessage(player, "Usage: weather <weather id>");
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.");
}
}
}
}

0 comments on commit 51e1afe

Please sign in to comment.