forked from space-syndicate/space-station-14
# Conflicts: # Content.IntegrationTests/Tests/PostMapInitTest.cs # Content.Server/Telephone/TelephoneSystem.cs # LICENSE.TXT # Resources/Prototypes/Datasets/ion_storm.yml # Resources/Prototypes/Entities/Structures/Machines/lathe.yml # Resources/Prototypes/Guidebook/rules.yml # Resources/Prototypes/Maps/meta.yml # Resources/Prototypes/SoundCollections/NukeMusic.yml # Resources/ServerInfo/Guidebook/Chemicals.xml # Resources/Textures/Structures/Wallmounts/posters.rsi/meta.json # Resources/Textures/Structures/Wallmounts/signs.rsi/meta.json
63 lines
1.8 KiB
C#
63 lines
1.8 KiB
C#
using System.Text;
|
|
using Content.Server.Administration.Managers;
|
|
using Content.Server.Afk;
|
|
using Content.Shared.Administration;
|
|
using Robust.Shared.Console;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Server.Administration.Commands;
|
|
|
|
[AnyCommand] // Corvax: Allow use to everyone
|
|
public sealed class AdminWhoCommand : IConsoleCommand
|
|
{
|
|
public string Command => "adminwho";
|
|
public string Description => "Returns a list of all admins on the server";
|
|
public string Help => "Usage: adminwho";
|
|
|
|
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;
|
|
foreach (var admin in adminMgr.ActiveAdmins)
|
|
{
|
|
var adminData = adminMgr.GetAdminData(admin)!;
|
|
DebugTools.AssertNotNull(adminData);
|
|
|
|
if (adminData.Stealth && !seeStealth)
|
|
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 (shell.Player is { } player && adminMgr.HasAdminFlag(player, AdminFlags.Admin))
|
|
{
|
|
if (afk.IsAfk(admin))
|
|
sb.Append(" [AFK]");
|
|
}
|
|
}
|
|
|
|
shell.WriteLine(sb.ToString());
|
|
}
|
|
}
|