GodModeCommand.java 1.31 KB
Newer Older
KingRainbow44's avatar
KingRainbow44 committed
1
2
3
4
package emu.grasscutter.command.commands;

import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
Melledy's avatar
Melledy committed
5
import emu.grasscutter.game.player.Player;
KingRainbow44's avatar
KingRainbow44 committed
6
7
8

import java.util.List;

9
10
import static emu.grasscutter.utils.Language.translate;

11
@Command(label = "godmode", usage = "godmode [on|off|toggle]", permission = "player.godmode", permissionTargeted = "player.godmode.others", description = "commands.godmode.description")
KingRainbow44's avatar
KingRainbow44 committed
12
13
14
public final class GodModeCommand implements CommandHandler {

    @Override
AnimeGitB's avatar
AnimeGitB committed
15
    public void execute(Player sender, Player targetPlayer, List<String> args) {
AnimeGitB's avatar
AnimeGitB committed
16
        boolean enabled = !targetPlayer.inGodmode();
xtaodada's avatar
xtaodada committed
17
        if (args.size() == 1) {
AnimeGitB's avatar
AnimeGitB committed
18
19
20
21
22
23
24
25
26
27
            switch (args.get(0).toLowerCase()) {
                case "on":
                    enabled = true;
                    break;
                case "off":
                    enabled = false;
                    break;
                case "toggle":
                    break;  // Already toggled
                default:
28
                    break;
xtaodada's avatar
xtaodada committed
29
30
31
            }
        }

AnimeGitB's avatar
AnimeGitB committed
32
        targetPlayer.setGodmode(enabled);
Secretboy's avatar
Secretboy committed
33
        CommandHandler.sendMessage(sender, translate(sender, "commands.godmode.success", (enabled ? translate(sender, "commands.status.enabled") : translate(sender, "commands.status.disabled")), targetPlayer.getNickname()));
KingRainbow44's avatar
KingRainbow44 committed
34
35
    }
}