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