Package net.canarymod.commandsys.commands

Source Code of net.canarymod.commandsys.commands.PrivateMessage

package net.canarymod.commandsys.commands;

import net.canarymod.Canary;
import net.canarymod.Translator;
import net.canarymod.api.entity.living.humanoid.Player;
import net.canarymod.chat.Colors;
import net.canarymod.chat.MessageReceiver;
import net.canarymod.commandsys.NativeCommand;
import net.visualillusionsent.utils.StringUtils;

/**
* Command to send a private message to another player 
*
* @author Chris (damagefilter)
*/
public class PrivateMessage implements NativeCommand {

    public void execute(MessageReceiver caller, String[] parameters) {
        Player target = Canary.getServer().matchPlayer(parameters[1]);
        String prefix = Colors.BLUE;
        if (caller instanceof Player) {
            prefix = ((Player) caller).getPrefix();
        }
        if (target != null) {
            caller.message(Colors.LIGHT_GRAY + "-> " + target.getPrefix() + target.getName() + Colors.WHITE + ": " + StringUtils.joinString(parameters, " ", 2));
            target.message(Colors.LIGHT_GRAY + "(MSG) " + prefix + caller.getName() + Colors.WHITE + ": " + StringUtils.joinString(parameters, " ", 2));
        }
        else {
            caller.notice(Translator.translateAndFormat("unknown player", parameters[1]));
        }
    }
}
TOP

Related Classes of net.canarymod.commandsys.commands.PrivateMessage

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.