Files
wwdpublic/Content.Server/Chat/Commands/SuicideCommand.cs
ilmenwe 8338b0c699 Removed Duplicate Using. Removed Unused Using. (#2163)
# Description

Removed duplicate using statements, removed unused using statements.
this will decrease the number of warnings a small bit, and decrease
unused dependency references in general.
---

# TODO

- [x] Remove double references.
- [x] Remove unused references.
---

# Changelog

🆑
- remove: double references in code
- remove: unused references in code that had double references.

Co-authored-by: ilmenwe <no@mail.com>

(cherry picked from commit 9b73c88feefff68223f083893505826dc021ddee)
2025-04-18 17:04:50 +03:00

60 lines
2.0 KiB
C#

using Content.Server.Popups;
using Content.Shared.Administration;
using Content.Shared.Mind;
using Robust.Shared.Console;
using Robust.Shared.Enums;
namespace Content.Server.Chat.Commands
{
[AnyCommand]
internal sealed class SuicideCommand : IConsoleCommand
{
[Dependency] private readonly IEntityManager _entityManager = default!;
public string Command => "suicide";
public string Description => Loc.GetString("suicide-command-description");
public string Help => Loc.GetString("suicide-command-help-text");
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player is not { } player)
{
shell.WriteError(Loc.GetString("shell-cannot-run-command-from-server"));
return;
}
if (player.Status != SessionStatus.InGame || player.AttachedEntity == null)
return;
var minds = _entityManager.System<SharedMindSystem>();
// This check also proves mind not-null for at the end when the mob is ghosted.
if (!minds.TryGetMind(player, out var mindId, out var mindComp) ||
mindComp.OwnedEntity is not { Valid: true } victim)
{
shell.WriteLine(Loc.GetString("suicide-command-no-mind"));
return;
}
var suicideSystem = _entityManager.System<SuicideSystem>();
if (_entityManager.HasComponent<AdminFrozenComponent>(victim))
{
var deniedMessage = Loc.GetString("suicide-command-denied");
shell.WriteLine(deniedMessage);
_entityManager.System<PopupSystem>()
.PopupEntity(deniedMessage, victim, victim);
return;
}
if (suicideSystem.Suicide(victim))
return;
shell.WriteLine(Loc.GetString("ghost-command-denied"));
shell.WriteLine(Loc.GetString("ghost-command-denied"));
}
}
}