Skip to content

Commit

Permalink
Localized entity command pro
Browse files Browse the repository at this point in the history
  • Loading branch information
beck-thompson committed Jan 9, 2025
1 parent 3a3ca66 commit f8b7bd3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
18 changes: 6 additions & 12 deletions Content.Server/_DV/FeedbackPopup/FeedbackPopupCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@
namespace Content.Server._DV.FeedbackPopup;

[AdminCommand(AdminFlags.Server)]
public sealed class FeedbackPopupCommand : IConsoleCommand
public sealed class FeedbackPopupCommand : LocalizedEntityCommands
{
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly IEntityManager _entities = default!;
[Dependency] private readonly SharedFeedbackOverwatchSystem _feedback = default!;

private SharedFeedbackOverwatchSystem? _feedback;
public override string Command => Loc.GetString("feedbackpopup-command-name");

public string Command => Loc.GetString("feedbackpopup-command-name");
public string Description => Loc.GetString("feedbackpopup-command-description");
public string Help => Loc.GetString("feedbackpopup-command-help", ("command", Command));

public void Execute(IConsoleShell shell, string argStr, string[] args)
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 2)
{
Expand All @@ -35,7 +31,7 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)

var netEnt = new NetEntity(entityUidInt);

if (!_entities.TryGetEntity(netEnt, out var target))
if (!EntityManager.TryGetEntity(netEnt, out var target))
{
shell.WriteLine(Loc.GetString("feedbackpopup-command-error-entity-not-found"));
return;
Expand All @@ -47,8 +43,6 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
return;
}

_feedback ??= _entities.System<SharedFeedbackOverwatchSystem>();

if (!_feedback.SendPopup(target, args[1]))
{
shell.WriteError(Loc.GetString("feedbackpopup-command-error-popup-send-fail"));
Expand All @@ -58,7 +52,7 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
shell.WriteLine(Loc.GetString("feedbackpopup-command-success"));
}

public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
if (args.Length == 1)
{
Expand Down
4 changes: 2 additions & 2 deletions Resources/Locale/en-US/_DV/feedbackpopup/feedbackpopup.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ feedbackpopup-discord-format-feedbackbody = {$feedback}
# Command strings
feedbackpopup-command-name = givefeedbackpopup
feedbackpopup-command-description = Gives the targeted player a feedback popup.
feedbackpopup-command-help = Usage: {$command} <playerUid> <prototypeId>
cmd-givefeedbackpopup-desc = Gives the targeted player a feedback popup.
cmd-givefeedbackpopup-help = Usage: givefeedbackpopup <playerUid> <prototypeId>
feedbackpopup-command-error-wrong-arguments = Wrong number of arguments.
feedbackpopup-command-error-invalid-uid = Invalid entity uid.
Expand Down

0 comments on commit f8b7bd3

Please sign in to comment.