static void TimerHandler([NotNull] Player player, [NotNull] CommandReader cmd) { string param = cmd.Next(); // List timers if (param == null) { ChatTimer[] list = ChatTimer.TimerList.OrderBy(timer => timer.TimeLeft).ToArray(); if (list.Length == 0) { player.Message("No timers running."); } else { player.Message("There are {0} timers running:", list.Length); foreach (ChatTimer timer in list) { player.Message(" #{0} \"{1}&S\" (started by {2}, {3} left)", timer.Id, timer.Message, timer.StartedBy, timer.TimeLeft.ToMiniString()); } } return; } // Abort a timer if (param.Equals("abort", StringComparison.OrdinalIgnoreCase)) { int timerId; if (cmd.NextInt(out timerId)) { ChatTimer timer = ChatTimer.FindTimerById(timerId); if (timer == null || !timer.IsRunning) { player.Message("Given timer (#{0}) does not exist.", timerId); } else { timer.Abort(); string abortMsg = String.Format("&Y(Timer) {0}&Y aborted a timer with {1} left: {2}", player.ClassyName, timer.TimeLeft.ToMiniString(), timer.Message); Chat.SendSay(player, abortMsg); } } else { CdTimer.PrintUsage(player); } return; } // Start a timer if (player.Info.IsMuted) { player.MessageMuted(); return; } if (player.DetectChatSpam()) { return; } TimeSpan duration; if (!param.TryParseMiniTimeSpan(out duration)) { CdTimer.PrintUsage(player); return; } if (duration > DateTimeUtil.MaxTimeSpan) { player.MessageMaxTimeSpan(); return; } if (duration < ChatTimer.MinDuration) { player.Message("Timer: Must be at least 1 second."); return; } string sayMessage; string message = cmd.NextAll(); if (String.IsNullOrWhiteSpace(message)) { sayMessage = String.Format("&Y(Timer) {0}&Y started a {1} timer", player.ClassyName, duration.ToMiniString()); } else { sayMessage = String.Format("&Y(Timer) {0}&Y started a {1} timer: {2}", player.ClassyName, duration.ToMiniString(), message); } Chat.SendSay(player, sayMessage); ChatTimer.Start(duration, message, player.Name); }