mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-24 00:11:31 +00:00
Add weather command
Signed-off-by: Jaida Wu <mlgmxyysd@meowcat.org>
This commit is contained in:
parent
f898795c11
commit
0dabb4c7c2
39
src/main/java/emu/grasscutter/command/commands/Weather.java
Normal file
39
src/main/java/emu/grasscutter/command/commands/Weather.java
Normal file
@ -0,0 +1,39 @@
|
||||
package emu.grasscutter.command.commands;
|
||||
|
||||
import emu.grasscutter.command.Command;
|
||||
import emu.grasscutter.command.CommandHandler;
|
||||
import emu.grasscutter.game.GenshinPlayer;
|
||||
import emu.grasscutter.game.props.ClimateType;
|
||||
import emu.grasscutter.server.packet.send.PacketSceneAreaWeatherNotify;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Command(label = "weather", usage = "weather <weatherId>",
|
||||
description = "Changes the weather.", aliases = {"w"}, permission = "player.weather")
|
||||
public class Weather implements CommandHandler {
|
||||
|
||||
@Override
|
||||
public void onCommand(GenshinPlayer sender, List<String> args) {
|
||||
if (sender == null) {
|
||||
CommandHandler.sendMessage(null, "Run this command in-game.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.size() < 1) {
|
||||
CommandHandler.sendMessage(sender, "Usage: weather <weatherId>");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
int weatherId = Integer.parseInt(args.get(0));
|
||||
|
||||
ClimateType climate = ClimateType.getTypeByValue(weatherId);
|
||||
|
||||
sender.getScene().setClimate(climate);
|
||||
sender.getScene().broadcastPacket(new PacketSceneAreaWeatherNotify(sender));
|
||||
CommandHandler.sendMessage(sender, "Changed weather to " + weatherId);
|
||||
} catch (NumberFormatException ignored) {
|
||||
CommandHandler.sendMessage(sender, "Invalid weather ID.");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user