Give station events command completions, cleanup (#8464)
This commit is contained in:
committed by
GitHub
parent
4f9f9e5942
commit
821df271c4
@@ -3,6 +3,7 @@ using Content.Shared.Administration;
|
|||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
using Robust.Shared.Console;
|
using Robust.Shared.Console;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace Content.Server.StationEvents
|
namespace Content.Server.StationEvents
|
||||||
{
|
{
|
||||||
@@ -10,13 +11,8 @@ namespace Content.Server.StationEvents
|
|||||||
public sealed class StationEventCommand : IConsoleCommand
|
public sealed class StationEventCommand : IConsoleCommand
|
||||||
{
|
{
|
||||||
public string Command => "events";
|
public string Command => "events";
|
||||||
public string Description => Loc.GetString("station-event-command-description");
|
public string Description => Loc.GetString("cmd-events-desc");
|
||||||
public string Help => Loc.GetString("station-event-command-help-text",
|
public string Help => Loc.GetString("cmd-events-help");
|
||||||
("runningHelp", Loc.GetString("station-event-command-running-help-text")),
|
|
||||||
("listHelp", Loc.GetString("station-event-command-list-help-text")),
|
|
||||||
("pauseHelp", Loc.GetString("station-event-command-pause-help-text")),
|
|
||||||
("resumeHelp", Loc.GetString("station-event-command-resume-help-text")),
|
|
||||||
("runHelp", Loc.GetString("station-event-command-run-help-text")));
|
|
||||||
|
|
||||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||||
{
|
{
|
||||||
@@ -51,7 +47,7 @@ namespace Content.Server.StationEvents
|
|||||||
shell.WriteLine(Loc.GetString("shell-wrong-arguments-number-need-specific",
|
shell.WriteLine(Loc.GetString("shell-wrong-arguments-number-need-specific",
|
||||||
("properAmount", 2),
|
("properAmount", 2),
|
||||||
("currentAmount", args.Length))
|
("currentAmount", args.Length))
|
||||||
+ $"\n{Loc.GetString("station-event-command-run-help-text")}");
|
+ $"\n{Help}");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,15 +79,23 @@ namespace Content.Server.StationEvents
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
shell.WriteLine(Loc.GetString("No station event running"));
|
shell.WriteLine(Loc.GetString("cmd-events-none-running"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void List(IConsoleShell shell, IPlayerSession? player)
|
private void List(IConsoleShell shell, IPlayerSession? player)
|
||||||
{
|
{
|
||||||
var resultText = Loc.GetString("station-event-command-event-list",
|
var events = EntitySystem.Get<StationEventSystem>();
|
||||||
("otherEvents", EntitySystem.Get<StationEventSystem>().GetEventNames()));
|
var sb = new StringBuilder();
|
||||||
shell.WriteLine(resultText);
|
|
||||||
|
sb.AppendLine(Loc.GetString("cmd-events-list-random"));
|
||||||
|
|
||||||
|
foreach (var stationEvents in events.StationEvents)
|
||||||
|
{
|
||||||
|
sb.AppendLine(stationEvents.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
shell.WriteLine(sb.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Pause(IConsoleShell shell, IPlayerSession? player)
|
private void Pause(IConsoleShell shell, IPlayerSession? player)
|
||||||
@@ -100,12 +104,12 @@ namespace Content.Server.StationEvents
|
|||||||
|
|
||||||
if (!stationEventSystem.Enabled)
|
if (!stationEventSystem.Enabled)
|
||||||
{
|
{
|
||||||
shell.WriteLine(Loc.GetString("station-event-command-events-already-paused-message"));
|
shell.WriteLine(Loc.GetString("cmd-events-already-paused"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stationEventSystem.Enabled = false;
|
stationEventSystem.Enabled = false;
|
||||||
shell.WriteLine(Loc.GetString("station-event-command-events-paused-message"));
|
shell.WriteLine(Loc.GetString("cmd-events-paused"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,12 +119,12 @@ namespace Content.Server.StationEvents
|
|||||||
|
|
||||||
if (stationEventSystem.Enabled)
|
if (stationEventSystem.Enabled)
|
||||||
{
|
{
|
||||||
shell.WriteLine(Loc.GetString("station-event-command-events-already-running-message"));
|
shell.WriteLine(Loc.GetString("cmd-events-already-running"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stationEventSystem.Enabled = true;
|
stationEventSystem.Enabled = true;
|
||||||
shell.WriteLine(Loc.GetString("station-event-command-events-resumed-message"));
|
shell.WriteLine(Loc.GetString("cmd-events-resumed"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,5 +133,39 @@ namespace Content.Server.StationEvents
|
|||||||
var resultText = EntitySystem.Get<StationEventSystem>().StopEvent();
|
var resultText = EntitySystem.Get<StationEventSystem>().StopEvent();
|
||||||
shell.WriteLine(resultText);
|
shell.WriteLine(resultText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
||||||
|
{
|
||||||
|
if (args.Length == 1)
|
||||||
|
{
|
||||||
|
var options = new[]
|
||||||
|
{
|
||||||
|
"list",
|
||||||
|
"running",
|
||||||
|
"pause",
|
||||||
|
"resume",
|
||||||
|
"stop",
|
||||||
|
"run"
|
||||||
|
};
|
||||||
|
|
||||||
|
return CompletionResult.FromHintOptions(options, Loc.GetString("cmd-events-arg-subcommand"));
|
||||||
|
}
|
||||||
|
|
||||||
|
var command = args[0];
|
||||||
|
|
||||||
|
if (args.Length != 2)
|
||||||
|
return CompletionResult.Empty;
|
||||||
|
|
||||||
|
if (command == "run")
|
||||||
|
{
|
||||||
|
var system = EntitySystem.Get<StationEventSystem>();
|
||||||
|
var options = new[] { "random" }.Concat(
|
||||||
|
system.StationEvents.Select(e => e.Name).OrderBy(e => e));
|
||||||
|
|
||||||
|
return CompletionResult.FromHintOptions(options, Loc.GetString("cmd-events-arg-run-eventName"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return CompletionResult.Empty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,22 +65,6 @@ namespace Content.Server.StationEvents
|
|||||||
|
|
||||||
private bool _enabled = true;
|
private bool _enabled = true;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Admins can get a list of all events available to run, regardless of whether their requirements have been met
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public string GetEventNames()
|
|
||||||
{
|
|
||||||
StringBuilder result = new StringBuilder();
|
|
||||||
|
|
||||||
foreach (var stationEvent in _stationEvents)
|
|
||||||
{
|
|
||||||
result.Append(stationEvent.Name + "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
return result.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Admins can forcibly run events by passing in the Name
|
/// Admins can forcibly run events by passing in the Name
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
station-event-command-description = Provides admin control to station events
|
### Localization for events console commands
|
||||||
station-event-command-help-text = events <running/list/pause/resume/stop/run <eventName/random>>
|
|
||||||
running: return the current running event
|
## 'events' command
|
||||||
list: return all event names that can be run
|
cmd-events-desc = Provides admin control to station events
|
||||||
pause: stop all random events from running and any one currently running
|
cmd-events-help = events <running/list/pause/resume/stop/run <eventName/random>>
|
||||||
resume: allow random events to run again
|
running: return the current running event
|
||||||
run <eventName/random>: start a particular event now; <eventName> is case-insensitive and not localized
|
list: return all event names that can be run
|
||||||
station-event-command-running-help-text = running: return the current running event
|
pause: stop all random events from running and any one currently running
|
||||||
station-event-command-list-help-text = list: return all event names that can be run
|
resume: allow random events to run again
|
||||||
station-event-command-pause-help-text = pause: stop all random events from running and any one currently running
|
run <eventName/random>: start a particular event now; <eventName> is case-insensitive and not localized
|
||||||
station-event-command-resume-help-text = resume: allow random events to run again
|
cmd-events-arg-subcommand = <subcommand>
|
||||||
station-event-command-run-help-text = run <eventName/random>: start a particular event now; <eventName> is case-insensitive and not localized
|
cmd-events-arg-run-eventName = <eventName>
|
||||||
station-event-command-no-event-running-message = No station event running
|
|
||||||
station-event-command-event-list = Random
|
cmd-events-none-running = No station event running
|
||||||
{$otherEvents}
|
cmd-events-list-random = Random
|
||||||
station-event-command-events-paused-message = Station events paused
|
cmd-events-paused = Station events paused
|
||||||
station-event-command-events-already-paused-message = Station events are already paused
|
cmd-events-already-paused = Station events are already paused
|
||||||
station-event-command-events-resumed-message = Station events resumed
|
cmd-events-resumed = Station events resumed
|
||||||
station-event-command-events-already-running-message = Station events are already running
|
cmd-events-already-running = Station events are already running
|
||||||
|
|||||||
Reference in New Issue
Block a user