    001    package net.minecraft.src;
    002
    003    import java.util.List;
    004    import net.minecraft.server.MinecraftServer;
    005
    006    public class CommandGive extends CommandBase
    007    {
    008        public String getCommandName()
    009        {
    010            return "give";
    011        }
    012
    013        public int func_82362_a()
    014        {
    015            return 2;
    016        }
    017
    018        public String getCommandUsage(ICommandSender par1ICommandSender)
    019        {
    020            return par1ICommandSender.translateString("commands.give.usage", new Object[0]);
    021        }
    022
    023        public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    024        {
    025            if (par2ArrayOfStr.length >= 2)
    026            {
    027                EntityPlayerMP var3 = func_82359_c(par1ICommandSender, par2ArrayOfStr[0]);
    028                int var4 = parseIntWithMin(par1ICommandSender, par2ArrayOfStr[1], 1);
    029                int var5 = 1;
    030                int var6 = 0;
    031
    032                if (Item.itemsList[var4] == null)
    033                {
    034                    throw new NumberInvalidException("commands.give.notFound", new Object[] {Integer.valueOf(var4)});
    035                }
    036                else
    037                {
    038                    if (par2ArrayOfStr.length >= 3)
    039                    {
    040                        var5 = parseIntBounded(par1ICommandSender, par2ArrayOfStr[2], 1, 64);
    041                    }
    042
    043                    if (par2ArrayOfStr.length >= 4)
    044                    {
    045                        var6 = parseInt(par1ICommandSender, par2ArrayOfStr[3]);
    046                    }
    047
    048                    ItemStack var7 = new ItemStack(var4, var5, var6);
    049                    EntityItem var8 = var3.dropPlayerItem(var7);
    050                    var8.delayBeforeCanPickup = 0;
    051                    notifyAdmins(par1ICommandSender, "commands.give.success", new Object[] {Item.itemsList[var4].func_77653_i(var7), Integer.valueOf(var4), Integer.valueOf(var5), var3.getEntityName()});
    052                }
    053            }
    054            else
    055            {
    056                throw new WrongUsageException("commands.give.usage", new Object[0]);
    057            }
    058        }
    059
    060        /**
    061         * Adds the strings available in this command to the given list of tab completion options.
    062         */
    063        public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    064        {
    065            return par2ArrayOfStr.length == 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, this.getPlayers()) : null;
    066        }
    067
    068        protected String[] getPlayers()
    069        {
    070            return MinecraftServer.getServer().getAllUsernames();
    071        }
    072
    073        public boolean func_82358_a(int par1)
    074        {
    075            return par1 == 0;
    076        }
    077    }