diff --git a/Content.Server/Traitor/Uplink/Commands/AddUplinkCommand.cs b/Content.Server/Traitor/Uplink/Commands/AddUplinkCommand.cs index 7d232f57e2..156a13e465 100644 --- a/Content.Server/Traitor/Uplink/Commands/AddUplinkCommand.cs +++ b/Content.Server/Traitor/Uplink/Commands/AddUplinkCommand.cs @@ -14,27 +14,47 @@ namespace Content.Server.Traitor.Uplink.Commands { public string Command => "adduplink"; - public string Description => "Creates uplink on selected item and link it to users account"; + public string Description => Loc.GetString("add-uplink-command-description"); - public string Help => "Usage: adduplink "; + public string Help => Loc.GetString("add-uplink-command-help"); + + + public CompletionResult GetCompletion(IConsoleShell shell, string[] args) + { + return args.Length switch + { + 1 => CompletionResult.FromHintOptions(CompletionHelper.SessionNames(), Loc.GetString("add-uplink-command-completion-1")), + 2 => CompletionResult.FromHint(Loc.GetString("add-uplink-command-completion-2")), + _ => CompletionResult.Empty + }; + } public void Execute(IConsoleShell shell, string argStr, string[] args) { - if (args.Length < 1) + if (args.Length > 2) { shell.WriteError(Loc.GetString("shell-wrong-arguments-number")); return; } - // Get player entity - if (!IoCManager.Resolve().TryGetSessionByUsername(args[0], out var session)) + IPlayerSession? session; + if (args.Length > 0) { - shell.WriteLine(Loc.GetString("shell-target-player-does-not-exist")); - return; + // Get player entity + if (!IoCManager.Resolve().TryGetSessionByUsername(args[0], out session)) + { + shell.WriteLine(Loc.GetString("shell-target-player-does-not-exist")); + return; + } } - if (session.AttachedEntity is not {} user) + else { - shell.WriteLine(Loc.GetString("Selected player doesn't controll any entity")); + session = (IPlayerSession?) shell.Player; + } + + if (session?.AttachedEntity is not { } user) + { + shell.WriteLine(Loc.GetString("add-uplink-command-error-1")); return; } @@ -72,7 +92,7 @@ namespace Content.Server.Traitor.Uplink.Commands if (!entityManager.EntitySysManager.GetEntitySystem() .AddUplink(user, uplinkAccount, uplinkEntity)) { - shell.WriteLine(Loc.GetString("Failed to add uplink to the player")); + shell.WriteLine(Loc.GetString("add-uplink-command-error-2")); return; } } diff --git a/Content.Server/Traitor/Uplink/UplinkSystem.cs b/Content.Server/Traitor/Uplink/UplinkSystem.cs index 2ca661a775..f5394fb9bf 100644 --- a/Content.Server/Traitor/Uplink/UplinkSystem.cs +++ b/Content.Server/Traitor/Uplink/UplinkSystem.cs @@ -188,6 +188,11 @@ namespace Content.Server.Traitor.Uplink var uplink = uplinkEntity.Value.EnsureComponent(); SetAccount(uplink, account); + if (!HasComp(uplinkEntity.Value)) + uplink.ActivatesInHands = true; + + // TODO add BUI. Currently can't be done outside of yaml -_- + return true; } diff --git a/Resources/Locale/en-US/administration/commands/add-uplink-command.ftl b/Resources/Locale/en-US/administration/commands/add-uplink-command.ftl new file mode 100644 index 0000000000..068f88dc5b --- /dev/null +++ b/Resources/Locale/en-US/administration/commands/add-uplink-command.ftl @@ -0,0 +1,7 @@ +add-uplink-command-description = Creates uplink on selected item and link it to users account +add-uplink-command-help = Usage: adduplink [username] [item-id] + +add-uplink-command-completion-1 = Username (defaults to self) +add-uplink-command-completion-2 = Uplink uid (default to PDA) +add-uplink-command-error-1 = Selected player doesn't control any entity +add-uplink-command-error-2 = Failed to add uplink to the player \ No newline at end of file