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