From 1725dd189ae3c27e983e491b3912b49ffc2b7529 Mon Sep 17 00:00:00 2001 From: AndresE55 <80334192+Leander-0@users.noreply.github.com> Date: Fri, 1 Mar 2024 20:26:06 -0500 Subject: [PATCH] showrules autocompletion (#1061) --- Content.Server/Info/ShowRulesCommand.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Content.Server/Info/ShowRulesCommand.cs b/Content.Server/Info/ShowRulesCommand.cs index 286e371b2c4..07107cf65c3 100644 --- a/Content.Server/Info/ShowRulesCommand.cs +++ b/Content.Server/Info/ShowRulesCommand.cs @@ -12,6 +12,7 @@ namespace Content.Server.Info; [AdminCommand(AdminFlags.Admin)] public sealed class ShowRulesCommand : IConsoleCommand { + [Dependency] private readonly IPlayerManager _playerManager = default!; public string Command => "showrules"; public string Description => "Opens the rules popup for the specified player."; public string Help => "showrules [seconds]"; @@ -63,4 +64,28 @@ public async void Execute(IConsoleShell shell, string argStr, string[] args) var player = IoCManager.Resolve().GetSessionByUserId(located.UserId); netManager.ServerSendMessage(message, player.ConnectedClient); } + + public CompletionResult GetCompletion(IConsoleShell shell, string[] args) + { + if (args.Length == 1) + { + return CompletionResult.FromHintOptions( + CompletionHelper.SessionNames(players: _playerManager), + Loc.GetString("")); + } + + if (args.Length == 2) + { + var durations = new CompletionOption[] + { + new("300", Loc.GetString("5 minutes")), + new("600", Loc.GetString("10 minutes")), + new("1200", Loc.GetString("20 minutes")), + }; + + return CompletionResult.FromHintOptions(durations, Loc.GetString("[seconds]")); + } + + return CompletionResult.Empty; + } }