Grasscutter/src/main/java/emu/grasscutter/command/commands/GodModeCommand.java

36 lines
1.3 KiB
Java
Raw Normal View History

2022-04-21 06:48:24 +08:00
package emu.grasscutter.command.commands;
import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
2022-04-27 12:24:25 +08:00
import emu.grasscutter.game.player.Player;
2022-04-21 06:48:24 +08:00
import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "godmode", usage = "godmode [on|off|toggle]", permission = "player.godmode", permissionTargeted = "player.godmode.others", description = "commands.godmode.description")
2022-04-21 06:48:24 +08:00
public final class GodModeCommand implements CommandHandler {
@Override
2022-05-04 14:32:09 +08:00
public void execute(Player sender, Player targetPlayer, List<String> args) {
2022-05-04 17:16:42 +08:00
boolean enabled = !targetPlayer.inGodmode();
2022-04-24 11:40:10 +08:00
if (args.size() == 1) {
2022-05-04 17:16:42 +08:00
switch (args.get(0).toLowerCase()) {
case "on":
enabled = true;
break;
case "off":
enabled = false;
break;
case "toggle":
break; // Already toggled
default:
break;
2022-04-24 11:40:10 +08:00
}
}
2022-05-04 17:16:42 +08:00
targetPlayer.setGodmode(enabled);
CommandHandler.sendMessage(sender, translate(sender, "commands.godmode.success", (enabled ? translate(sender, "commands.status.enabled") : translate(sender, "commands.status.disabled")), targetPlayer.getNickname()));
2022-04-21 06:48:24 +08:00
}
}