static void BlockDBUndoConfirmCallback([NotNull] Player player, [NotNull] object tag, bool fromConsole) {
if (player == null) throw new ArgumentNullException("player");
if (tag == null) throw new ArgumentNullException("tag");
BlockDBUndoArgs args = (BlockDBUndoArgs)tag;
string cmdName = (args.Area == null ? "UndoArea" : "UndoPlayer");
if (args.Not) cmdName += "Not";
// Produce
Vector3I[] coords;
if (args.Area != null) {
coords = new[] { args.Area.MinVertex, args.Area.MaxVertex };
} else {
coords = new Vector3I[0];
}
// Produce a brief param description for BlockDBDrawOperation
string description;
if (args.CountLimit > 0) {
if (args.Targets.Length == 0) {
description = args.CountLimit.ToStringInvariant();
} else if (args.Not) {
description = String.Format("{0} by everyone except {1}",
args.CountLimit,
args.Targets.JoinToString(p => p.Name));
} else {
description = String.Format("{0} by {1}",
args.CountLimit,
args.Targets.JoinToString(p => p.Name));
}
} else {
if (args.Targets.Length == 0) {
description = args.AgeLimit.ToMiniString();
} else if (args.Not) {
description = String.Format("{0} by everyone except {1}",
args.AgeLimit.ToMiniString(),
args.Targets.JoinToString(p => p.Name));
} else {
description = String.Format("{0} by {1}",
args.AgeLimit.ToMiniString(),
args.Targets.JoinToString(p => p.Name));
}
}
// start undoing (using DrawOperation infrastructure)
var op = new BlockDBDrawOperation(player, cmdName, description, coords.Length);
op.Prepare(coords, args.Entries);
// log operation
string targetList;
if (args.Targets.Length == 0) {
targetList = "(everyone)";
} else if (args.Not) {
targetList = "(everyone) except " + args.Targets.JoinToClassyString();
} else {
targetList = args.Targets.JoinToClassyString();
}
Logger.Log(LogType.UserActivity,
"{0}: Player {1} will undo {2} changes (limit of {3}) by {4} on world {5}",
cmdName,
player.Name,
args.Entries.Length,
args.CountLimit == 0 ? args.AgeLimit.ToMiniString() : args.CountLimit.ToStringInvariant(),
targetList,
args.World.Name);
op.Begin();
}