Exemplo n.º 1
0
        async void doStop(CommandArgs e)
        {
            if (e.Parameters.Count == 0)
            {
                e.Player.SendErrorMessage($"Invalid syntax! Proper syntax: {Commands.Specifier}timeline stop <name>");
                return;
            }

            string name = e.Parameters[0];

            if (!Running.Exists(t => t.Name.Equals(name, StringComparison.OrdinalIgnoreCase)))
            {
                e.Player.SendErrorMessage($"'{name}' isn't running.");
            }
            else
            {
                if (!e.Player.CanUseTimeline(Path.Combine(TShock.SavePath, name.EndsWith(".txt") ? name : $"{name}.txt")))
                {
                    e.Player.SendErrorMessage("You don't have access to this timeline.");
                    return;
                }

                Timeline timeline = Running.Find(t => t.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
                e.Player.SendInfoMessage($"Stopping {timeline.Name}...");
                await timeline.Stop();

                e.Player.SendSuccessMessage($"{timeline.Name} stopped.");
            }
        }