Skip to content

Commit

Permalink
AdminWho is back?
Browse files Browse the repository at this point in the history
  • Loading branch information
RedBurningPhoenix committed Sep 2, 2024
1 parent a625d9e commit d90c42f
Showing 1 changed file with 17 additions and 23 deletions.
40 changes: 17 additions & 23 deletions Content.Server/Administration/Commands/AdminWhoCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Content.Server.Administration.Commands;

[AdminCommand(AdminFlags.Admin)]
[AnyCommand]
public sealed class AdminWhoCommand : IConsoleCommand
{
public string Command => "adminwho";
Expand All @@ -19,42 +19,36 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
var adminMgr = IoCManager.Resolve<IAdminManager>();
var afk = IoCManager.Resolve<IAfkManager>();

var seeStealth = true;

// If null it (hopefully) means it is being called from the console.
if (shell.Player != null)
{
var playerData = adminMgr.GetAdminData(shell.Player);

seeStealth = playerData != null && playerData.CanStealth();
}

var sb = new StringBuilder();
var first = true;

// WD start
var isAdmin = shell.Player is {} player && adminMgr.HasAdminFlag(player, AdminFlags.Admin);
foreach (var admin in adminMgr.ActiveAdmins)
{
if (!first)
sb.Append('\n');
first = false;

var adminData = adminMgr.GetAdminData(admin)!;
DebugTools.AssertNotNull(adminData);

if (adminData.Stealth && !seeStealth)
if (!isAdmin && adminData.Stealth)
continue;

if (!first)
sb.Append('\n');
first = false;

sb.Append(admin.Name);
if (adminData.Title is { } title)
sb.Append($": [{title}]");

if (adminData.Stealth)
sb.Append(" (S)");
if (!isAdmin)
continue;

if (shell.Player is { } player && adminMgr.HasAdminFlag(player, AdminFlags.Admin))
{
if (afk.IsAfk(admin))
sb.Append(" [AFK]");
}
if (afk.IsAfk(admin))
sb.Append(" [AFK]");

if (adminData.Stealth)
sb.Append(" [Stealth]");
// WD end
}

shell.WriteLine(sb.ToString());
Expand Down

0 comments on commit d90c42f

Please sign in to comment.