Commit 01b190bc authored by Magix's avatar Magix Committed by GitHub
Browse files

UPGRADE TO 1.1.0 POG

Merge `development` into `stable`
parents 6b81b888 1beddf16
package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.props.PlayerProperty;
import emu.grasscutter.game.player.Player;
import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "setworldlevel", usage = "setworldlevel <level>",
description = "Sets your world level (Relog to see proper effects)",
aliases = {"setworldlvl"}, permission = "player.setworldlevel")
public final class SetWorldLevelCommand implements CommandHandler {
@Override
public void execute(GenshinPlayer sender, List<String> args) {
if (sender == null) {
CommandHandler.sendMessage(null, "Run this command in-game.");
return; // TODO: set player's world level from console or other players
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (targetPlayer == null) {
CommandHandler.sendMessage(sender, translate("commands.execution.need_target"));
return;
}
if (args.size() < 1) {
CommandHandler.sendMessage(sender, "Usage: setworldlevel <level>");
CommandHandler.sendMessage(sender, translate("commands.setWorldLevel.usage"));
return;
}
try {
int level = Integer.parseInt(args.get(0));
if (level > 8 || level < 0) {
CommandHandler.sendMessage(sender, translate("commands.setWorldLevel.value_error"));
return;
}
// Set in both world and player props
sender.getWorld().setWorldLevel(level);
sender.setProperty(PlayerProperty.PROP_PLAYER_WORLD_LEVEL, level);
targetPlayer.getWorld().setWorldLevel(level);
targetPlayer.setWorldLevel(level);
sender.dropMessage("World level set to " + level + ".");
CommandHandler.sendMessage(sender, translate("commands.setWorldLevel.success", Integer.toString(level)));
} catch (NumberFormatException ignored) {
CommandHandler.sendMessage(null, "Invalid world level.");
CommandHandler.sendMessage(null, translate("commands.setWorldLevel.invalid_world_level"));
}
}
}
......@@ -3,21 +3,23 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.player.Player;
import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "stop", usage = "stop",
description = "Stops the server", permission = "server.stop")
public final class StopCommand implements CommandHandler {
@Override
public void execute(GenshinPlayer sender, List<String> args) {
CommandHandler.sendMessage(null, "Server shutting down...");
for (GenshinPlayer p : Grasscutter.getGameServer().getPlayers().values()) {
CommandHandler.sendMessage(p, "Server shutting down...");
public void execute(Player sender, Player targetPlayer, List<String> args) {
CommandHandler.sendMessage(null, translate("commands.stop.success"));
for (Player p : Grasscutter.getGameServer().getPlayers().values()) {
CommandHandler.sendMessage(p, translate("commands.stop.success"));
}
System.exit(1);
System.exit(1000);
}
}
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment