ListObjectivesCommand localisation and completion (#17630)

This commit is contained in:
crazybrain23
2023-06-28 14:47:46 +01:00
committed by GitHub
parent 200ef24445
commit d75d715d23
3 changed files with 21 additions and 7 deletions

View File

@@ -8,12 +8,10 @@ using Robust.Shared.Console;
namespace Content.Server.Objectives.Commands
{
[AdminCommand(AdminFlags.Logs)]
public sealed class ListObjectivesCommand : IConsoleCommand
public sealed class ListObjectivesCommand : LocalizedCommands
{
public string Command => "lsobjectives";
public string Description => "Lists all objectives in a players mind.";
public string Help => "lsobjectives [<username>]";
public void Execute(IConsoleShell shell, string argStr, string[] args)
public override string Command => "lsobjectives";
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
IPlayerData? data;
@@ -23,14 +21,14 @@ namespace Content.Server.Objectives.Commands
}
else if (player == null || !IoCManager.Resolve<IPlayerManager>().TryGetPlayerDataByUsername(args[0], out data))
{
shell.WriteLine("Can't find the playerdata.");
shell.WriteError(LocalizationManager.GetString("shell-target-player-does-not-exist"));
return;
}
var mind = data.ContentData()?.Mind;
if (mind == null)
{
shell.WriteLine("Can't find the mind.");
shell.WriteError(LocalizationManager.GetString("shell-target-entity-does-not-have-message", ("missing", "mind")));
return;
}
@@ -46,5 +44,15 @@ namespace Content.Server.Objectives.Commands
}
}
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
if (args.Length == 1)
{
return CompletionResult.FromHintOptions(CompletionHelper.SessionNames(), LocalizationManager.GetString("shell-argument-username-hint"));
}
return CompletionResult.Empty;
}
}
}

View File

@@ -0,0 +1,3 @@
# lsobjectives
cmd-lsobjectives-desc = Lists all objectives in a players mind.
cmd-lsobjectives-help = Usage: lsobjectives <username>

View File

@@ -42,3 +42,6 @@ shell-argument-number-must-be-between = Argument {$index} must be a number betwe
shell-argument-station-id-invalid = Argument {$index} must be a valid station id!
shell-argument-map-id-invalid = Argument {$index} must be a valid map id!
shell-argument-number-invalid = Argument {$index} must be a valid number!
# Hints
shell-argument-username-hint = <username>