    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        /**
    010         * Returns true if the given command sender is allowed to use this command.
    011         */
    012        public boolean canCommandSenderUseCommand(ICommandSender par1ICommandSender)
    013        {
    014            return (!MinecraftServer.getServer().isSinglePlayer() || MinecraftServer.getServer().getCurrentPlayerCount() > 1) && super.canCommandSenderUseCommand(par1ICommandSender);
    015        }
    016
    017        public List getCommandAliases()
    018        {
    019            return Arrays.asList(new String[] {"w", "msg"});
    020        }
    021
    022        public String getCommandName()
    023        {
    024            return "tell";
    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 = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(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 = joinString(par2ArrayOfStr, 1);
    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    }