2020-12-03 03:40:47 +01:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
using Content.Server.Administration;
|
|
|
|
|
|
using Content.Shared.Administration;
|
2023-08-30 21:46:11 -07:00
|
|
|
|
using Content.Shared.Mind;
|
|
|
|
|
|
using Content.Shared.Roles;
|
2021-02-11 01:13:03 -08:00
|
|
|
|
using Robust.Server.Player;
|
2021-02-01 16:49:43 -08:00
|
|
|
|
using Robust.Shared.Console;
|
2020-12-03 03:40:47 +01:00
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Server.Mind.Commands
|
2020-12-03 03:40:47 +01:00
|
|
|
|
{
|
|
|
|
|
|
[AdminCommand(AdminFlags.Admin)]
|
2022-02-16 00:23:23 -07:00
|
|
|
|
public sealed class MindInfoCommand : IConsoleCommand
|
2020-12-03 03:40:47 +01:00
|
|
|
|
{
|
2023-08-28 16:53:24 -07:00
|
|
|
|
[Dependency] private readonly IEntityManager _entities = default!;
|
2020-12-03 03:40:47 +01:00
|
|
|
|
|
2023-08-28 16:53:24 -07:00
|
|
|
|
public string Command => "mindinfo";
|
2020-12-03 03:40:47 +01:00
|
|
|
|
public string Description => "Lists info for the mind of a specific player.";
|
|
|
|
|
|
public string Help => "mindinfo <session ID>";
|
|
|
|
|
|
|
2021-02-01 16:49:43 -08:00
|
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
2020-12-03 03:40:47 +01:00
|
|
|
|
{
|
|
|
|
|
|
if (args.Length != 1)
|
|
|
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
|
shell.WriteLine("Expected exactly 1 argument.");
|
2020-12-03 03:40:47 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var mgr = IoCManager.Resolve<IPlayerManager>();
|
2023-08-28 16:53:24 -07:00
|
|
|
|
if (!mgr.TryGetSessionByUsername(args[0], out var session))
|
2020-12-03 03:40:47 +01:00
|
|
|
|
{
|
2021-03-16 15:50:20 +01:00
|
|
|
|
shell.WriteLine("Can't find that mind");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2020-12-03 03:40:47 +01:00
|
|
|
|
|
2023-08-30 21:46:11 -07:00
|
|
|
|
var minds = _entities.System<SharedMindSystem>();
|
2023-08-28 16:53:24 -07:00
|
|
|
|
if (!minds.TryGetMind(session, out var mindId, out var mind))
|
2020-12-03 03:40:47 +01:00
|
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
|
shell.WriteLine("Can't find that mind");
|
2021-03-16 15:50:20 +01:00
|
|
|
|
return;
|
2020-12-03 03:40:47 +01:00
|
|
|
|
}
|
2021-03-16 15:50:20 +01:00
|
|
|
|
|
|
|
|
|
|
var builder = new StringBuilder();
|
2023-06-18 11:33:19 -07:00
|
|
|
|
builder.AppendFormat("player: {0}, mob: {1}\nroles: ", mind.UserId, mind.OwnedEntity);
|
2023-08-28 16:53:24 -07:00
|
|
|
|
|
2023-08-30 21:46:11 -07:00
|
|
|
|
var roles = _entities.System<SharedRoleSystem>();
|
2024-10-10 10:48:56 +02:00
|
|
|
|
foreach (var role in roles.MindGetAllRoleInfo(mindId))
|
2021-03-16 15:50:20 +01:00
|
|
|
|
{
|
|
|
|
|
|
builder.AppendFormat("{0} ", role.Name);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
shell.WriteLine(builder.ToString());
|
2020-12-03 03:40:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-03-16 15:50:20 +01:00
|
|
|
|
}
|