    001package net.minecraft.command;
    002
    003import java.util.Arrays;
    004import java.util.List;
    005import net.minecraft.entity.player.EntityPlayer;
    006import net.minecraft.entity.player.EntityPlayerMP;
    007import net.minecraft.server.MinecraftServer;
    008
    009public class CommandServerMessage extends CommandBase
    010{
    011    public List getCommandAliases()
    012    {
    013        return Arrays.asList(new String[] {"w", "msg"});
    014    }
    015
    016    public String getCommandName()
    017    {
    018        return "tell";
    019    }
    020
    021    /**
    022     * Return the required permission level for this command.
    023     */
    024    public int getRequiredPermissionLevel()
    025    {
    026        return 0;
    027    }
    028
    029    public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    030    {
    031        if (par2ArrayOfStr.length < 2)
    032        {
    033            throw new WrongUsageException("commands.message.usage", new Object[0]);
    034        }
    035        else
    036        {
    037            EntityPlayerMP var3 = func_82359_c(par1ICommandSender, par2ArrayOfStr[0]);
    038
    039            if (var3 == null)
    040            {
    041                throw new PlayerNotFoundException();
    042            }
    043            else if (var3 == par1ICommandSender)
    044            {
    045                throw new PlayerNotFoundException("commands.message.sameTarget", new Object[0]);
    046            }
    047            else
    048            {
    049                String var4 = func_82361_a(par1ICommandSender, par2ArrayOfStr, 1, !(par1ICommandSender instanceof EntityPlayer));
    050                var3.sendChatToPlayer("\u00a77\u00a7o" + var3.translateString("commands.message.display.incoming", new Object[] {par1ICommandSender.getCommandSenderName(), var4}));
    051                par1ICommandSender.sendChatToPlayer("\u00a77\u00a7o" + par1ICommandSender.translateString("commands.message.display.outgoing", new Object[] {var3.getCommandSenderName(), var4}));
    052            }
    053        }
    054    }
    055
    056    /**
    057     * Adds the strings available in this command to the given list of tab completion options.
    058     */
    059    public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    060    {
    061        return getListOfStringsMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getAllUsernames());
    062    }
    063
    064    /**
    065     * Return whether the specified command parameter index is a username parameter.
    066     */
    067    public boolean isUsernameIndex(int par1)
    068    {
    069        return par1 == 0;
    070    }
    071}