UnBanCommand.java 1.1 KB
Newer Older
Yazawazi's avatar
Yazawazi committed
1
2
3
4
5
6
7
8
9
10
11
package emu.grasscutter.command.commands;

import java.util.List;

import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.Account;
import emu.grasscutter.game.player.Player;

@Command(
    label = "unban",
12
13
    permission = "server.ban",
    targetRequirement = Command.TargetRequirement.PLAYER
Yazawazi's avatar
Yazawazi committed
14
15
16
)
public final class UnBanCommand implements CommandHandler {

17
18
    private boolean unBanAccount(Player targetPlayer) {
        Account account = targetPlayer.getAccount();
Yazawazi's avatar
Yazawazi committed
19
20

        if (account == null) {
21
            return false;
Yazawazi's avatar
Yazawazi committed
22
23
24
25
26
27
28
29
30
31
32
33
34
        }

        account.setBanReason(null);
        account.setBanEndTime(0);
        account.setBanStartTime(0);
        account.setBanned(false);
        account.save();

        return true;
    }

    @Override
    public void execute(Player sender, Player targetPlayer, List<String> args) {
35
36
        if (unBanAccount(targetPlayer)) {
            CommandHandler.sendTranslatedMessage(sender, "commands.unban.success");
Yazawazi's avatar
Yazawazi committed
37
        } else {
38
            CommandHandler.sendTranslatedMessage(sender, "commands.unban.failure");
Yazawazi's avatar
Yazawazi committed
39
40
        }
    }
github-actions's avatar
github-actions committed
41
}