Admin notes (#7259)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
43
Content.Server/Administration/Notes/AdminNotesSystem.cs
Normal file
43
Content.Server/Administration/Notes/AdminNotesSystem.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using Content.Server.Administration.Commands;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Console;
|
||||
|
||||
namespace Content.Server.Administration.Notes;
|
||||
|
||||
public sealed class AdminNotesSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IConsoleHost _console = default!;
|
||||
[Dependency] private readonly IAdminNotesManager _notes = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<GetVerbsEvent<Verb>>(AddVerbs);
|
||||
}
|
||||
|
||||
private void AddVerbs(GetVerbsEvent<Verb> ev)
|
||||
{
|
||||
if (EntityManager.GetComponentOrNull<ActorComponent>(ev.User) is not {PlayerSession: var user} ||
|
||||
EntityManager.GetComponentOrNull<ActorComponent>(ev.Target) is not {PlayerSession: var target})
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_notes.CanView(user))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var verb = new Verb
|
||||
{
|
||||
Text = Loc.GetString("admin-notes-verb-text"),
|
||||
Category = VerbCategory.Admin,
|
||||
IconTexture = "/Textures/Interface/VerbIcons/examine.svg.192dpi.png",
|
||||
Act = () => _console.RemoteExecuteCommand(user, $"{OpenAdminNotesCommand.CommandName} \"{target.UserId}\""),
|
||||
Impact = LogImpact.Low
|
||||
};
|
||||
|
||||
ev.Verbs.Add(verb);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user