Skip to content

Commit

Permalink
showrules autocompletion (#1061)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leander-0 committed Mar 2, 2024
1 parent d701581 commit 1725dd1
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Content.Server/Info/ShowRulesCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <username> [seconds]";
Expand Down Expand Up @@ -63,4 +64,28 @@ public async void Execute(IConsoleShell shell, string argStr, string[] args)
var player = IoCManager.Resolve<IPlayerManager>().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("<username>"));
}

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;
}
}

0 comments on commit 1725dd1

Please sign in to comment.