From 09d7f7adf62e63602cac1262bce6de8d55daaf83 Mon Sep 17 00:00:00 2001 From: Kyle Tyo <36606155+VerinSenpai@users.noreply.github.com> Date: Tue, 24 Jun 2025 22:28:13 -0400 Subject: [PATCH] Electrocute command cleanup and localization (#38563) * hey look I knocked out a todo :shockedface: * Update Resources/Locale/en-US/electrocution/electrocute-command.ftl --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> --- .../Electrocution/ElectrocuteCommand.cs | 84 +++++++++---------- .../electrocution/electrocute-command.ftl | 5 +- 2 files changed, 41 insertions(+), 48 deletions(-) diff --git a/Content.Server/Electrocution/ElectrocuteCommand.cs b/Content.Server/Electrocution/ElectrocuteCommand.cs index 75eb64c1bb..c0d0ecf740 100644 --- a/Content.Server/Electrocution/ElectrocuteCommand.cs +++ b/Content.Server/Electrocution/ElectrocuteCommand.cs @@ -3,55 +3,47 @@ using Content.Shared.Administration; using Content.Shared.StatusEffect; using Robust.Shared.Console; -namespace Content.Server.Electrocution +namespace Content.Server.Electrocution; + +[AdminCommand(AdminFlags.Fun)] +public sealed class ElectrocuteCommand : LocalizedEntityCommands { - [AdminCommand(AdminFlags.Fun)] - public sealed class ElectrocuteCommand : IConsoleCommand + [Dependency] private readonly ElectrocutionSystem _electrocution = default!; + [Dependency] private readonly StatusEffectsSystem _statusEffects = default!; + + public override string Command => "electrocute"; + + [ValidatePrototypeId] + private const string ElectrocutionStatusEffect = "Electrocution"; + + public override void Execute(IConsoleShell shell, string argStr, string[] args) { - [Dependency] private readonly IEntityManager _entManager = default!; - - public string Command => "electrocute"; - public string Description => Loc.GetString("electrocute-command-description"); - public string Help => $"{Command} "; - - [ValidatePrototypeId] - public const string ElectrocutionStatusEffect = "Electrocution"; - - public void Execute(IConsoleShell shell, string argStr, string[] args) + if (args.Length is < 1 or > 3) { - if (args.Length < 1) - { - // TODO: Localize this. - shell.WriteError("Not enough arguments!"); - return; - } - - if (!NetEntity.TryParse(args[0], out var uidNet) || - !_entManager.TryGetEntity(uidNet, out var uid) || - !_entManager.EntityExists(uid)) - { - shell.WriteError($"Invalid entity specified!"); - return; - } - - if (!_entManager.EntitySysManager.GetEntitySystem().CanApplyEffect(uid.Value, ElectrocutionStatusEffect)) - { - shell.WriteError(Loc.GetString("electrocute-command-entity-cannot-be-electrocuted")); - return; - } - - if (args.Length < 2 || !int.TryParse(args[1], out var seconds)) - { - seconds = 10; - } - - if (args.Length < 3 || !int.TryParse(args[2], out var damage)) - { - damage = 10; - } - - _entManager.EntitySysManager.GetEntitySystem() - .TryDoElectrocution(uid.Value, null, damage, TimeSpan.FromSeconds(seconds), refresh: true, ignoreInsulation: true); + shell.WriteError(Loc.GetString($"shell-need-between-arguments", + ("lower", 1), + ("upper", 3))); + return; } + + if (!NetEntity.TryParse(args[0], out var uidNet) || !EntityManager.TryGetEntity(uidNet, out var uid) || !EntityManager.EntityExists(uid)) + { + shell.WriteError(Loc.GetString($"shell-could-not-find-entity-with-uid", ("uid", args[0]))); + return; + } + + if (!_statusEffects.CanApplyEffect(uid.Value, ElectrocutionStatusEffect)) + { + shell.WriteError(Loc.GetString("cmd-electrocute-entity-cannot-be-electrocuted")); + return; + } + + if (args.Length < 2 || !int.TryParse(args[1], out var seconds)) + seconds = 10; + + if (args.Length < 3 || !int.TryParse(args[2], out var damage)) + damage = 10; + + _electrocution.TryDoElectrocution(uid.Value, null, damage, TimeSpan.FromSeconds(seconds), refresh: true, ignoreInsulation: true); } } diff --git a/Resources/Locale/en-US/electrocution/electrocute-command.ftl b/Resources/Locale/en-US/electrocution/electrocute-command.ftl index edd05f2950..1a982b40fb 100644 --- a/Resources/Locale/en-US/electrocution/electrocute-command.ftl +++ b/Resources/Locale/en-US/electrocution/electrocute-command.ftl @@ -1,2 +1,3 @@ -electrocute-command-description = Electrocutes the specified entity, defaults to 10 seconds and 10 damage. Shocking! -electrocute-command-entity-cannot-be-electrocuted = You cannot electrocute that entity! +cmd-electrocute-desc = Electrocutes the specified entity, defaults to 10 seconds and 10 damage. Shocking! +cmd-electrocute-help = Usage: electrocute [seconds] [damage] +cmd-electrocute-entity-cannot-be-electrocuted = You cannot electrocute that entity!