    001package net.minecraft.scoreboard;
    002
    003import net.minecraft.command.CommandBase;
    004import net.minecraft.command.CommandException;
    005import net.minecraft.command.ICommandSender;
    006import net.minecraft.command.WrongUsageException;
    007import net.minecraft.tileentity.TileEntityCommandBlock;
    008
    009public class ServerCommandTestFor extends CommandBase
    010{
    011    public String getCommandName()
    012    {
    013        return "testfor";
    014    }
    015
    016    /**
    017     * Return the required permission level for this command.
    018     */
    019    public int getRequiredPermissionLevel()
    020    {
    021        return 2;
    022    }
    023
    024    public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    025    {
    026        if (par2ArrayOfStr.length != 1)
    027        {
    028            throw new WrongUsageException("commands.testfor.usage", new Object[0]);
    029        }
    030        else if (!(par1ICommandSender instanceof TileEntityCommandBlock))
    031        {
    032            throw new CommandException("commands.testfor.failed", new Object[0]);
    033        }
    034        else
    035        {
    036            func_82359_c(par1ICommandSender, par2ArrayOfStr[0]);
    037        }
    038    }
    039
    040    /**
    041     * Return whether the specified command parameter index is a username parameter.
    042     */
    043    public boolean isUsernameIndex(String[] par1ArrayOfStr, int par2)
    044    {
    045        return par2 == 0;
    046    }
    047}