    001    package net.minecraft.src;
    002
    003    import java.util.List;
    004    import net.minecraft.server.MinecraftServer;
    005
    006    public class CommandDifficulty extends CommandBase
    007    {
    008        private static final String[] field_82365_a = new String[] {"options.difficulty.peaceful", "options.difficulty.easy", "options.difficulty.normal", "options.difficulty.hard"};
    009
    010        public String getCommandName()
    011        {
    012            return "difficulty";
    013        }
    014
    015        public int func_82362_a()
    016        {
    017            return 2;
    018        }
    019
    020        public String getCommandUsage(ICommandSender par1ICommandSender)
    021        {
    022            return par1ICommandSender.translateString("commands.difficulty.usage", new Object[0]);
    023        }
    024
    025        public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    026        {
    027            if (par2ArrayOfStr.length > 0)
    028            {
    029                int var3 = this.func_82364_d(par1ICommandSender, par2ArrayOfStr[0]);
    030                MinecraftServer.getServer().setDifficultyForAllWorlds(var3);
    031                String var4 = StatCollector.translateToLocal(field_82365_a[var3]);
    032                notifyAdmins(par1ICommandSender, 1, "commands.difficulty.success", new Object[] {var4});
    033            }
    034            else
    035            {
    036                throw new WrongUsageException("commands.difficulty.usage", new Object[0]);
    037            }
    038        }
    039
    040        protected int func_82364_d(ICommandSender par1ICommandSender, String par2Str)
    041        {
    042            return !par2Str.equalsIgnoreCase("peaceful") && !par2Str.equalsIgnoreCase("p") ? (!par2Str.equalsIgnoreCase("easy") && !par2Str.equalsIgnoreCase("e") ? (!par2Str.equalsIgnoreCase("normal") && !par2Str.equalsIgnoreCase("n") ? (!par2Str.equalsIgnoreCase("hard") && !par2Str.equalsIgnoreCase("h") ? parseIntBounded(par1ICommandSender, par2Str, 0, 3) : 3) : 2) : 1) : 0;
    043        }
    044
    045        /**
    046         * Adds the strings available in this command to the given list of tab completion options.
    047         */
    048        public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    049        {
    050            return par2ArrayOfStr.length == 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"peaceful", "easy", "normal", "hard"}): null;
    051        }
    052    }