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