Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Essentials/Commands/CleanupModule.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Sandbox.Game.Entities;
using Sandbox.Game.World;
using Torch.Commands;
using NLog;
using VRage.Game.Entity;

namespace Essentials.Commands
{
Expand Down Expand Up @@ -75,6 +77,9 @@ private IEnumerable<MyCubeGrid> ScanConditions(IReadOnlyList<string> args)
case "ownedby":
conditions.Add(g => OwnedBy(g, parameter));
break;
case "name":
conditions.Add(g => NameMatches(g, parameter));
break;
default:
Context.Respond($"Unknown argument '{arg}'");
yield break;
Expand All @@ -89,6 +94,12 @@ private IEnumerable<MyCubeGrid> ScanConditions(IReadOnlyList<string> args)
}
}

private bool NameMatches(MyCubeGrid grid, string str)
{
var regex = new Regex(str);
return regex.IsMatch(grid.DisplayName ?? "");
}

private bool BlocksLessThan(MyCubeGrid grid, string str)
{
if (int.TryParse(str, out int count))
Expand Down