mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* add user id to adminlogs command, allow opening logs for specific player * replace ban list with opening player logs in ahelp window * add entity logs verb * make it less obvious I blatantly copied stuff from admin notes * player log verb now actually working as intended * use logic, not call command * implement TryGetLastMind and TryGetLastMindOwner * replace double condition with TryGetLastMind * oops * Apply suggestion from @AJCM-git --------- Co-authored-by: AJCM-git <60196617+AJCM-git@users.noreply.github.com>
57 lines
1.9 KiB
C#
57 lines
1.9 KiB
C#
using System.Linq;
|
|
using Content.Server.Administration.Managers;
|
|
using Content.Server.Mind;
|
|
using Content.Shared.Administration;
|
|
using Content.Shared.Mind;
|
|
using Content.Shared.Mind.Components;
|
|
using Robust.Shared.Network;
|
|
|
|
namespace Content.Server.Administration.Systems;
|
|
|
|
/// <summary>
|
|
/// Server-side of the quick info system.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Just a simple "replies to requests from authorized clients".
|
|
/// </remarks>
|
|
/// <seealso cref="QuickInfoShared" />
|
|
public sealed partial class AdminQuickInfoSystem : EntitySystem
|
|
{
|
|
[Dependency] private IAdminManager _adminManager = null!;
|
|
[Dependency] private MindSystem _mind = null!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeNetworkEvent<QuickInfoShared.Request>(HandleRequest);
|
|
}
|
|
|
|
private void HandleRequest(QuickInfoShared.Request ev, EntitySessionEventArgs args)
|
|
{
|
|
if (!_adminManager.HasAdminFlag(args.SenderSession, QuickInfoShared.RequiredFlag))
|
|
{
|
|
Log.Warning($"{args.SenderSession} tried to fetch entity quick info without required permissions!");
|
|
return;
|
|
}
|
|
|
|
var responses = ev.Entities.Select(e =>
|
|
{
|
|
if (!TryGetEntity(e, out var ent))
|
|
return new QuickInfoShared.SingleEntityInfo(e, false, "", "", null);
|
|
|
|
NetUserId? lastPlayer = null;
|
|
|
|
// Check the last mind that was attached to the entity and get its userid.
|
|
if (_mind.TryGetLastMind(ent.Value, out var lastMind))
|
|
{
|
|
lastPlayer = lastMind.Value.Comp.UserId;
|
|
}
|
|
var metadata = MetaData(ent.Value);
|
|
return new QuickInfoShared.SingleEntityInfo(e, true, metadata.EntityName, metadata.EntityPrototype?.ID, lastPlayer);
|
|
})
|
|
.ToArray();
|
|
|
|
RaiseNetworkEvent(new QuickInfoShared.Response { Entities = responses }, args.SenderSession);
|
|
}
|
|
}
|