    001    package net.minecraft.src;
    002
    003    import java.util.List;
    004    import net.minecraft.server.MinecraftServer;
    005
    006    public class CommandClearInventory extends CommandBase
    007    {
    008        public String getCommandName()
    009        {
    010            return "clear";
    011        }
    012
    013        public String getCommandUsage(ICommandSender par1ICommandSender)
    014        {
    015            return par1ICommandSender.translateString("commands.clear.usage", new Object[0]);
    016        }
    017
    018        /**
    019         * Return the required permission level for this command.
    020         */
    021        public int getRequiredPermissionLevel()
    022        {
    023            return 2;
    024        }
    025
    026        public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    027        {
    028            EntityPlayerMP var3 = par2ArrayOfStr.length == 0 ? getCommandSenderAsPlayer(par1ICommandSender) : func_82359_c(par1ICommandSender, par2ArrayOfStr[0]);
    029            int var4 = par2ArrayOfStr.length >= 2 ? parseIntWithMin(par1ICommandSender, par2ArrayOfStr[1], 1) : -1;
    030            int var5 = par2ArrayOfStr.length >= 3 ? parseIntWithMin(par1ICommandSender, par2ArrayOfStr[2], 0) : -1;
    031            int var6 = var3.inventory.clearInventory(var4, var5);
    032            var3.inventorySlots.updateCraftingResults();
    033            notifyAdmins(par1ICommandSender, "commands.clear.success", new Object[] {var3.getEntityName(), Integer.valueOf(var6)});
    034        }
    035
    036        /**
    037         * Adds the strings available in this command to the given list of tab completion options.
    038         */
    039        public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    040        {
    041            return par2ArrayOfStr.length == 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, this.getAllOnlineUsernames()) : null;
    042        }
    043
    044        /**
    045         * Return all usernames currently connected to the server.
    046         */
    047        protected String[] getAllOnlineUsernames()
    048        {
    049            return MinecraftServer.getServer().getAllUsernames();
    050        }
    051
    052        /**
    053         * Return whether the specified command parameter index is a username parameter.
    054         */
    055        public boolean isUsernameIndex(int par1)
    056        {
    057            return par1 == 0;
    058        }
    059    }