KickCommand.java 1.24 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;

方块君's avatar
方块君 committed
11
@Command(label = "kick", usage = "kick", permission = "server.kick", description = "commands.kick.description")
KingRainbow44's avatar
KingRainbow44 committed
12
13
14
public final class KickCommand implements CommandHandler {

    @Override
AnimeGitB's avatar
AnimeGitB committed
15
    public void execute(Player sender, Player targetPlayer, List<String> args) {
KingRainbow44's avatar
KingRainbow44 committed
16
        if (targetPlayer == null) {
17
            CommandHandler.sendMessage(sender, translate("commands.execution.need_target"));
KingRainbow44's avatar
KingRainbow44 committed
18
19
20
21
            return;
        }

        if (sender != null) {
22
23
24
            CommandHandler.sendMessage(sender, translate("commands.kick.player_kick_player", 
                    Integer.toString(sender.getAccount().getPlayerUid()), sender.getAccount().getUsername(),
                    Integer.toString(targetPlayer.getUid()), targetPlayer.getAccount().getUsername()));
25
        } else {
26
            CommandHandler.sendMessage(null, translate("commands.kick.server_kick_player", Integer.toString(targetPlayer.getUid()), targetPlayer.getAccount().getUsername()));
KingRainbow44's avatar
KingRainbow44 committed
27
28
29
30
31
        }

        targetPlayer.getSession().close();
    }
}