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

AnimeGitB's avatar
AnimeGitB committed
11
@Command(label = "kick", usage = "kick",
KingRainbow44's avatar
KingRainbow44 committed
12
13
14
15
        description = "Kicks the specified player from the server (WIP)", permission = "server.kick")
public final class KickCommand implements CommandHandler {

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

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

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