Files
Delta-v/Content.Server/_DV/Administration/Commands/ListLawsCommand.cs
T
DisposableCrewmember42 3c0d4ab253 feat: Various Admin QOL features (#5436)
* feat: added lslaws command

* feat: add lswatchlisted command

* tweak: nicer formatting for lswatchlisted

* tweak: nicer formatting for lslaws

* feat: lsobjectives lists everyone's objectives if no user specified

* feat: mark ghosted players in players tab

* docs: add missing DeltaV patch comment

* feat: only alert admins if meatspiking player characters

* feat: always alert about station explosions, don't spam off-station alerts

* feat: stripping alert tweaks

* feat: admin alert on low hour latejoin

* refactor: forgot to make onspawncomplete non-async, wasn't necessary after all

* feat: EORG alerts

* feat: getping command

* refactor: remove unused imports, format

* refactor: early return in onspawncomplete

* feat: add coordinate link to eorg destroy alert

* tweak: cache watchlist data to avoid db calls, use in lswatchlisted

* fix: null-check in OnNoteAdded

* feat: watchlist indicator on admin overlay

* feat: optionally mark watchlisted in f7 players

* feat: refresh admin playerlist data on wl change

* fix: update player list after cache write

* feat: add tp links to prayer messages

* tweak: don't alert when uncuffing self

* tweak: lower uncuff other alert impact if mindshielded

* docs: add deltav comments to imports

* refactor: address review comments

* style: deltav comments on same line as change

* performance: get metadata only if objectives > 0

* fix: actually check user if explosion gridPos not on station

* style: remove extraneous newlines

* refactor: use fancy getOrNew method

* feat: refresh player list UI if marking pref changed

* feat: latejoin alert hours configurable

* fix: also list objectives for non-humanoids and dead people
2026-04-04 16:38:32 +02:00

83 lines
2.8 KiB
C#

using Content.Server.Administration;
using Content.Shared.Administration;
using Content.Shared.Silicons.Laws.Components;
using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server._DV.Administration.Commands;
[AdminCommand(AdminFlags.Admin)]
public sealed class ListLawsCommand : LocalizedEntityCommands
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPlayerManager _player = default!;
public override string Command => "lslaws";
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length > 1)
{
shell.WriteLine(Help);
return;
}
switch (args.Length)
{
case 0:
foreach (var (ent, lawProvider) in _entityManager.AllEntities<SiliconLawProviderComponent>())
{
WriteLawReport(shell, ent, lawProvider);
}
break;
case 1:
if (!_player.TryGetSessionByUsername(args[0], out var session) ||
!_entityManager.TryGetComponent<SiliconLawProviderComponent>(session.AttachedEntity,
out var provider))
{
shell.WriteError(Loc.GetString("cmd-lslaws-error-bad-player"));
return;
}
WriteLawReport(shell, session.AttachedEntity.Value, provider);
break;
default:
shell.WriteLine(Help);
break;
}
}
private void WriteLawReport(IConsoleShell shell, EntityUid ent, SiliconLawProviderComponent lawProvider)
{
shell.WriteLine("");
_entityManager.TryGetComponent<MetaDataComponent>(ent, out var metaData);
var entityName = metaData?.EntityName;
shell.WriteMarkup(_player.TryGetSessionByEntity(ent, out var session)
? $"[bold]{entityName}[/bold] ({ent.Id}, [color=red]{session.Name}[/color], subverted: {lawProvider.Subverted})"
: $"[bold]{entityName}[/bold] ({ent.Id}, subverted: {lawProvider.Subverted})");
shell.WriteLine($"Base Lawset: {lawProvider.Laws.Id}");
if (lawProvider.Lawset is { } lawset)
{
foreach (var siliconLaw in lawset.Laws)
{
shell.WriteLine($"{siliconLaw.Order}: {Loc.GetString(siliconLaw.LawString)}");
}
}
else
{
shell.WriteLine("Unable to retrieve laws.");
}
}
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
return args.Length == 1
? CompletionResult.FromOptions(CompletionHelper.SessionNames())
: CompletionResult.Empty;
}
}