int[] GetIds(Player p, string[] parts, out string[] names) { int count = Math.Max(1, parts.Length - 1); List <int> ids = new List <int>(); names = new string[count]; for (int i = 0; i < names.Length; i++) { names[i] = PlayerInfo.FindOfflineNameMatches(p, parts[i]); if (names[i] == null) { return(null); } Group grp = Group.GroupIn(names[i]); bool canUndo = p == null || grp.Permission < p.Rank || p.name.CaselessEq(names[i]); if (!canUndo) { MessageTooHighRank(p, "undo", false); return(null); } ids.AddRange(NameConverter.FindIds(names[i])); } return(ids.ToArray()); }
int[] GetIds(Player p, string[] parts, CommandData data, out string[] names) { int count = Math.Max(1, parts.Length - 1); List <int> ids = new List <int>(); names = new string[count]; for (int i = 0; i < names.Length; i++) { names[i] = PlayerDB.MatchNames(p, parts[i]); if (names[i] == null) { return(null); } Group grp = PlayerInfo.GetGroup(names[i]); if (!p.name.CaselessEq(names[i])) { if (!CheckRank(p, data, grp.Permission, "undo", false)) { return(null); } } ids.AddRange(NameConverter.FindIds(names[i])); } return(ids.ToArray()); }
void UndoLastDrawOp(Player p) { UndoDrawOpEntry[] entries = p.DrawOps.Items; if (entries.Length == 0) { p.Message("You have no draw operations to undo."); p.Message("Try using %T/Undo [timespan] %Sinstead."); return; } for (int i = entries.Length - 1; i >= 0; i--) { UndoDrawOpEntry entry = entries[i]; if (entry.DrawOpName == "UndoSelf") { continue; } p.DrawOps.Remove(entry); UndoSelfDrawOp op = new UndoSelfDrawOp(); op.who = p.name; op.ids = NameConverter.FindIds(p.name); op.Start = entry.Start; op.End = entry.End; DrawOpPerformer.Do(op, null, p, new Vec3S32[] { Vec3U16.MinVal, Vec3U16.MaxVal }); p.Message("Undo performed."); return; } p.Message("Unable to undo any draw operations, as all of the " + "past 50 draw operations are %T/Undo %Sor %T/Undo [timespan]"); p.Message("Try using %T/Undo [timespan] %Sinstead"); }
public override void Use(Player p, string message, CommandData data) { TimeSpan delta = TimeSpan.Zero; bool area = message.CaselessStarts("area "); if (area) message = message.Substring("area ".Length); if (message.Length == 0) message = p.name; string[] parts = message.SplitSpaces(); if (parts.Length >= 2) { if (!CommandParser.GetTimespan(p, parts[1], ref delta, "highlight the past", "s")) return; } else { delta = TimeSpan.FromMinutes(30); } parts[0] = PlayerDB.MatchNames(p, parts[0]); if (parts[0] == null) return; int[] ids = NameConverter.FindIds(parts[0]); if (!area) { Vec3S32[] marks = new Vec3S32[] { Vec3U16.MinVal, Vec3U16.MaxVal }; HighlightPlayer(p, delta, parts[0], ids, marks); } else { p.Message("Place or break two blocks to determine the edges."); HighlightAreaArgs args = new HighlightAreaArgs(); args.ids = ids; args.who = parts[0]; args.delta = delta; p.MakeSelection(2, "Selecting region for %SHighlight", args, DoHighlightArea); } }
void UndoSelf(Player p, TimeSpan delta) { UndoDrawOp op = new UndoSelfDrawOp(); op.Start = DateTime.UtcNow.Subtract(delta); op.who = p.name; op.ids = NameConverter.FindIds(p.name); DrawOpPerformer.Do(op, null, p, new Vec3S32[] { Vec3U16.MinVal, Vec3U16.MaxVal }); if (op.found) { p.Message("Undid your changes for the past &b{0}", delta.Shorten(true)); Logger.Log(LogType.UserActivity, "{0} undid their own actions for the past {1}", p.name, delta.Shorten(true)); } else { p.Message("No changes found by you in the past &b{0}", delta.Shorten(true)); } }
static int[] GetIds(Player p, CommandData data, string[] parts, out string[] names) { int count = Math.Max(1, parts.Length - 1); List <int> ids = new List <int>(); names = new string[count]; for (int i = 0; i < names.Length; i++) { names[i] = PlayerDB.MatchNames(p, parts[i]); if (names[i] == null) { return(null); } Group grp = Group.GroupIn(names[i]); if (!CheckRank(p, data, names[i], grp.Permission, "prune", false)) { return(null); } ids.AddRange(NameConverter.FindIds(names[i])); } return(ids.ToArray()); }
public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output) { int[] ids = NameConverter.FindIds(Player.name); if (ids.Length == 0) { return; } this.output = output; // can't use "using" as it creates a local var, and read lock reference may be changed by DrawOpPerformer class try { BlockDBReadLock = Level.BlockDB.Locker.AccquireRead(); if (Level.BlockDB.FindChangesBy(ids, Start, End, out dims, RedoBlock)) { return; } } finally { if (BlockDBReadLock != null) { BlockDBReadLock.Dispose(); } } this.output = null; }