    001    package net.minecraft.src;
    002
    003    import java.util.List;
    004    import java.util.Random;
    005    import net.minecraft.server.MinecraftServer;
    006
    007    public class CommandWeather extends CommandBase
    008    {
    009        public String getCommandName()
    010        {
    011            return "weather";
    012        }
    013
    014        /**
    015         * Return the required permission level for this command.
    016         */
    017        public int getRequiredPermissionLevel()
    018        {
    019            return 2;
    020        }
    021
    022        public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    023        {
    024            if (par2ArrayOfStr.length < 1)
    025            {
    026                throw new WrongUsageException("commands.weather.usage", new Object[0]);
    027            }
    028            else
    029            {
    030                int var3 = (300 + (new Random()).nextInt(600)) * 20;
    031
    032                if (par2ArrayOfStr.length >= 2)
    033                {
    034                    var3 = parseIntBounded(par1ICommandSender, par2ArrayOfStr[1], 1, 1000000) * 20;
    035                }
    036
    037                WorldServer var4 = MinecraftServer.getServer().worldServers[0];
    038                WorldInfo var5 = var4.getWorldInfo();
    039                var5.setRainTime(var3);
    040                var5.setThunderTime(var3);
    041
    042                if ("clear".equalsIgnoreCase(par2ArrayOfStr[0]))
    043                {
    044                    var5.setRaining(false);
    045                    var5.setThundering(false);
    046                    notifyAdmins(par1ICommandSender, "commands.weather.clear", new Object[0]);
    047                }
    048                else if ("rain".equalsIgnoreCase(par2ArrayOfStr[0]))
    049                {
    050                    var5.setRaining(true);
    051                    var5.setThundering(false);
    052                    notifyAdmins(par1ICommandSender, "commands.weather.rain", new Object[0]);
    053                }
    054                else if ("thunder".equalsIgnoreCase(par2ArrayOfStr[0]))
    055                {
    056                    var5.setRaining(true);
    057                    var5.setThundering(true);
    058                    notifyAdmins(par1ICommandSender, "commands.weather.thunder", new Object[0]);
    059                }
    060            }
    061        }
    062
    063        /**
    064         * Adds the strings available in this command to the given list of tab completion options.
    065         */
    066        public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    067        {
    068            return par2ArrayOfStr.length == 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"clear", "rain", "thunder"}): null;
    069        }
    070    }