Ejemplo n.º 1
0
        static bool HighlightBlocks(Player p, DateTime start, UndoCache cache)
        {
            UndoFormatArgs args   = new UndoFormatArgs(p, start, DateTime.MaxValue, null);
            UndoFormat     format = new UndoFormatOnline(cache);

            UndoFormat.DoHighlight(null, format, args);
            return(args.Stop);
        }
Ejemplo n.º 2
0
        public override void Use(Player p, string message)
        {
            TimeSpan delta;
            bool     found = false;

            if (Player.IsSuper(p))
            {
                MessageInGameOnly(p); return;
            }
            if (message == "")
            {
                message = p.name + " 1800";
            }
            string[] args = message.Split(' ');

            if (args.Length >= 2)
            {
                if (!args[1].TryParseShort(p, 's', "highlight the past", out delta))
                {
                    return;
                }
            }
            else if (ParseTimespan(args[0], out delta))
            {
                args[0] = p.name;
            }
            else
            {
                delta = TimeSpan.FromMinutes(30);
            }

            DateTime start = DateTime.UtcNow.Subtract(delta);
            Player   who   = PlayerInfo.Find(args[0]);
            bool     done  = false;

            if (who != null)
            {
                found = true;
                UndoCache cache = who.UndoBuffer;
                using (IDisposable locker = cache.ClearLock.AccquireReadLock()) {
                    done = HighlightBlocks(p, start, cache);
                }
            }

            if (!done)
            {
                UndoFormatArgs undoArgs = new UndoFormatArgs(p, start, DateTime.MaxValue, null);
                UndoFormat.DoHighlight(args[0].ToLower(), ref found, undoArgs);
            }

            if (found)
            {
                Player.Message(p, "Now highlighting past &b{0} %Sfor {1}",
                               delta.Shorten(), PlayerInfo.GetColoredName(p, args[0]));
                Player.Message(p, "&cUse /reload to un-highlight");
            }
            else
            {
                Player.Message(p, "Could not find player specified.");
            }
        }