From: Kyle Tyo <36606155+VerinSenpai@users.noreply.github.com> Date: Sat, 28 Jun 2025 11:11:08 +0000 (-0400) Subject: AddBodyPartCommand localization. (#38612) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=2c4cae2af994b49b9b00a08df959a67ef47ef594;p=space-station-14.git AddBodyPartCommand localization. (#38612) commit --- diff --git a/Content.Server/Administration/Commands/AddBodyPartCommand.cs b/Content.Server/Administration/Commands/AddBodyPartCommand.cs index 892a88d41a..a28fa93ad0 100644 --- a/Content.Server/Administration/Commands/AddBodyPartCommand.cs +++ b/Content.Server/Administration/Commands/AddBodyPartCommand.cs @@ -3,52 +3,41 @@ using Content.Shared.Administration; using Content.Shared.Body.Part; using Robust.Shared.Console; -namespace Content.Server.Administration.Commands +namespace Content.Server.Administration.Commands; + +[AdminCommand(AdminFlags.Admin)] +public sealed class AddBodyPartCommand : LocalizedEntityCommands { - [AdminCommand(AdminFlags.Admin)] - public sealed class AddBodyPartCommand : IConsoleCommand - { - [Dependency] private readonly IEntityManager _entManager = default!; + [Dependency] private readonly BodySystem _bodySystem = default!; - public string Command => "addbodypart"; - public string Description => "Adds a given entity to a containing body."; - public string Help => "Usage: addbodypart "; + public override string Command => "addbodypart"; - public void Execute(IConsoleShell shell, string argStr, string[] args) + public override void Execute(IConsoleShell shell, string argStr, string[] args) + { + if (args.Length != 4) { - if (args.Length != 3) - { - shell.WriteError(Loc.GetString("shell-wrong-arguments-number")); - return; - } - - if (!NetEntity.TryParse(args[0], out var childNetId)) - { - shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number")); - return; - } - - if (!NetEntity.TryParse(args[1], out var parentNetId)) - { - shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number")); - return; - } - - var childId = _entManager.GetEntity(childNetId); - var parentId = _entManager.GetEntity(parentNetId); - var bodySystem = _entManager.System(); + shell.WriteError(Loc.GetString("shell-wrong-arguments-number")); + return; + } + if (!NetEntity.TryParse(args[0], out var childNetId) || !EntityManager.TryGetEntity(childNetId, out var childId)) + { + shell.WriteError(Loc.GetString("shell-invalid-entity-uid", ("uid", args[0]))); + return; + } + if (!NetEntity.TryParse(args[1], out var parentNetId) || !EntityManager.TryGetEntity(parentNetId, out var parentId)) + { + shell.WriteError(Loc.GetString("shell-invalid-entity-uid", ("uid", args[1]))); + return; + } - if (Enum.TryParse(args[3], out var partType) && - bodySystem.TryCreatePartSlotAndAttach(parentId, args[2], childId, partType)) - { - shell.WriteLine($@"Added {childId} to {parentId}."); - } - else - { - shell.WriteError($@"Could not add {childId} to {parentId}."); - } + if (Enum.TryParse(args[3], out var partType) && + _bodySystem.TryCreatePartSlotAndAttach(parentId.Value, args[2], childId.Value, partType)) + { + shell.WriteLine($@"Added {childId} to {parentId}."); } + else + shell.WriteError($@"Could not add {childId} to {parentId}."); } } diff --git a/Resources/Locale/en-US/commands/add-body-part-command.ftl b/Resources/Locale/en-US/commands/add-body-part-command.ftl new file mode 100644 index 0000000000..6a7a54f730 --- /dev/null +++ b/Resources/Locale/en-US/commands/add-body-part-command.ftl @@ -0,0 +1,2 @@ +cmd-addbodypart-desc = Adds a given entity to a containing body. +cmd-addbodypart-help = Usage: addbodypart