SendMessageCommand.java 1.12 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 = "say", usage = "say <message>", description = "Sends a message to a player as the server",
KingRainbow44's avatar
KingRainbow44 committed
12
13
14
15
        aliases = {"sendservmsg", "sendservermessage", "sendmessage"}, permission = "server.sendmessage")
public final class SendMessageCommand implements CommandHandler {

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

AnimeGitB's avatar
AnimeGitB committed
26
27
        String message = String.join(" ", args);
        CommandHandler.sendMessage(targetPlayer, message);
28
        CommandHandler.sendMessage(sender, translate("commands.sendMessage.success"));
KingRainbow44's avatar
KingRainbow44 committed
29
    }
Jaida Wu's avatar
Jaida Wu committed
30
}