Example #1
0
        private static void ChangeWeatherHandler(Player player, Command cmd)
        {
            string worldName   = cmd.Next();
            string weatherName = cmd.Next();

            // make sure that both parameters are given (and no extra ones)
            if (String.IsNullOrEmpty(worldName) || String.IsNullOrEmpty(weatherName) || cmd.HasNext)
            {
                CdChangeWeather.PrintUsage(player);
                return;
            }

            // parse weather name
            WeatherType weather;

            if (!EnumUtil.TryParse(weatherName, out weather, true))
            {
                player.Message("Unrecognized weather type: {0}", weatherName);
                CdChangeWeather.PrintUsage(player);
                return;
            }

            // find world by name
            World world = WorldManager.FindWorldOrPrintMatches(player, worldName);

            if (world == null)
            {
                return;
            }

            player.Message("Changed weather of {0}&S to {1}", world.ClassyName, weather);
            world.Players.Send(Packet.EnvWeatherType((int)weather));
        }