Search in sources :

Example 6 with IMessageRecipient

use of com.earth2me.essentials.messaging.IMessageRecipient in project Essentials by EssentialsX.

the class Commandmsg method run.

@Override
public void run(Server server, CommandSource sender, String commandLabel, String[] args) throws Exception {
    if (args.length < 2 || args[0].trim().length() < 2 || args[1].trim().isEmpty()) {
        throw new NotEnoughArgumentsException();
    }
    String message = getFinalArg(args, 1);
    boolean canWildcard;
    if (sender.isPlayer()) {
        User user = ess.getUser(sender.getPlayer());
        if (user.isMuted()) {
            throw new Exception(tl("voiceSilenced"));
        }
        message = FormatUtil.formatMessage(user, "essentials.msg", message);
        canWildcard = user.isAuthorized("essentials.msg.multiple");
    } else {
        message = FormatUtil.replaceFormat(message);
        canWildcard = true;
    }
    // Sending messages to console
    if (args[0].equalsIgnoreCase(Console.NAME)) {
        IMessageRecipient messageSender = sender.isPlayer() ? ess.getUser(sender.getPlayer()) : Console.getInstance();
        messageSender.sendMessage(Console.getInstance(), message);
        return;
    }
    loopOnlinePlayers(server, sender, canWildcard, canWildcard, args[0], new String[] { message });
}
Also used : User(com.earth2me.essentials.User) IMessageRecipient(com.earth2me.essentials.messaging.IMessageRecipient)

Aggregations

IMessageRecipient (com.earth2me.essentials.messaging.IMessageRecipient)6 User (com.earth2me.essentials.User)4