Files
tbd-station-14/Content.Server/Ghost/Ghost.cs
no 37099e481e Prevent admin-frozen players from ghosting or suiciding, add "Freeze And Mute" verb (#27813)
* prevent admin-frozen players from ghosting or suiciding

* Add "Freeze and Mute" admin verb

* Allow "Freeze And Mute" admin verb when player is already frozen but not muted

* Remove redundant scream handler (scream action just emotes, duh)

* AdminFrozenSystem: clean imports

* Update Content.Server/Chat/Commands/SuicideCommand.cs

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>

* Update Ghost.cs

* retrigger ci (empty commit)

---------

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2024-05-12 10:35:30 -04:00

51 lines
1.7 KiB
C#

using Content.Server.GameTicking;
using Content.Server.Popups;
using Content.Shared.Administration;
using Content.Shared.Mind;
using Robust.Shared.Console;
namespace Content.Server.Ghost
{
[AnyCommand]
public sealed class Ghost : IConsoleCommand
{
[Dependency] private readonly IEntityManager _entities = default!;
public string Command => "ghost";
public string Description => Loc.GetString("ghost-command-description");
public string Help => Loc.GetString("ghost-command-help-text");
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player;
if (player == null)
{
shell.WriteLine(Loc.GetString("ghost-command-no-session"));
return;
}
if (player.AttachedEntity is { Valid: true } frozen &&
_entities.HasComponent<AdminFrozenComponent>(frozen))
{
var deniedMessage = Loc.GetString("ghost-command-denied");
shell.WriteLine(deniedMessage);
_entities.System<PopupSystem>()
.PopupEntity(deniedMessage, frozen, frozen);
return;
}
var minds = _entities.System<SharedMindSystem>();
if (!minds.TryGetMind(player, out var mindId, out var mind))
{
mindId = minds.CreateMind(player.UserId);
mind = _entities.GetComponent<MindComponent>(mindId);
}
if (!_entities.System<GameTicker>().OnGhostAttempt(mindId, true, true, mind))
{
shell.WriteLine(Loc.GetString("ghost-command-denied"));
}
}
}
}