namespace Content.Server.Chat.Commands
{
[AdminCommand(AdminFlags.Adminchat)]
- internal sealed class AdminChatCommand : IConsoleCommand
+ internal sealed class AdminChatCommand : LocalizedCommands
{
- public string Command => "asay";
- public string Description => "Send chat messages to the private admin chat channel.";
- public string Help => "asay <text>";
+ [Dependency] private readonly IChatManager _chatManager = default!;
- public void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override string Command => "asay";
+
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player;
if (player == null)
{
- shell.WriteError("You can't run this command locally.");
+ shell.WriteError(Loc.GetString($"shell-cannot-run-command-from-server"));
return;
}
if (string.IsNullOrEmpty(message))
return;
- IoCManager.Resolve<IChatManager>().TrySendOOCMessage(player, message, OOCChatType.Admin);
+ _chatManager.TrySendOOCMessage(player, message, OOCChatType.Admin);
}
}
}
namespace Content.Server.Chat.Commands
{
[AnyCommand]
- internal sealed class MeCommand : IConsoleCommand
+ internal sealed class MeCommand : LocalizedEntityCommands
{
- public string Command => "me";
- public string Description => "Perform an action.";
- public string Help => "me <text>";
+ [Dependency] private readonly ChatSystem _chatSystem = default!;
- public void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override string Command => "me";
+
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player is not { } player)
{
- shell.WriteError("This command cannot be run from the server.");
+ shell.WriteError(Loc.GetString($"shell-cannot-run-command-from-server"));
return;
}
if (player.AttachedEntity is not {} playerEntity)
{
- shell.WriteError("You don't have an entity!");
+ shell.WriteError(Loc.GetString($"shell-must-be-attached-to-entity"));
return;
}
if (string.IsNullOrEmpty(message))
return;
- IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ChatSystem>()
- .TrySendInGameICMessage(playerEntity, message, InGameICChatType.Emote, ChatTransmitRange.Normal, false, shell, player);
+ _chatSystem.TrySendInGameICMessage(playerEntity, message, InGameICChatType.Emote, ChatTransmitRange.Normal, false, shell, player);
}
}
}
namespace Content.Server.Chat.Commands
{
[AnyCommand]
- internal sealed class OOCCommand : IConsoleCommand
+ internal sealed class OOCCommand : LocalizedCommands
{
- public string Command => "ooc";
- public string Description => "Send Out Of Character chat messages.";
- public string Help => "ooc <text>";
+ [Dependency] private readonly IChatManager _chatManager = default!;
- public void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override string Command => "ooc";
+
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player is not { } player)
{
- shell.WriteError("This command cannot be run from the server.");
+ shell.WriteError(Loc.GetString($"shell-cannot-run-command-from-server"));
return;
}
if (string.IsNullOrEmpty(message))
return;
- IoCManager.Resolve<IChatManager>().TrySendOOCMessage(player, message, OOCChatType.OOC);
+ _chatManager.TrySendOOCMessage(player, message, OOCChatType.OOC);
}
}
}
namespace Content.Server.Chat.Commands
{
[AnyCommand]
- internal sealed class SayCommand : IConsoleCommand
+ internal sealed class SayCommand : LocalizedEntityCommands
{
- public string Command => "say";
- public string Description => "Send chat messages to the local channel or a specified radio channel.";
- public string Help => "say <text>";
+ [Dependency] private readonly ChatSystem _chatSystem = default!;
+ public override string Command => "say";
- public void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player is not { } player)
{
if (player.AttachedEntity is not {} playerEntity)
{
- shell.WriteError("You don't have an entity!");
+ shell.WriteError(Loc.GetString($"shell-must-be-attached-to-entity"));
return;
}
if (string.IsNullOrEmpty(message))
return;
- IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ChatSystem>()
- .TrySendInGameICMessage(playerEntity, message, InGameICChatType.Speak, ChatTransmitRange.Normal, false, shell, player);
+ _chatSystem.TrySendInGameICMessage(playerEntity, message, InGameICChatType.Speak, ChatTransmitRange.Normal, false, shell, player);
}
}
}
namespace Content.Server.Chat.Commands;
[AdminCommand(AdminFlags.Server)]
-public sealed class SetLOOCCommand : IConsoleCommand
+public sealed class SetLoocCommand : LocalizedCommands
{
- public string Command => "setlooc";
- public string Description => Loc.GetString("set-looc-command-description");
- public string Help => Loc.GetString("set-looc-command-help");
- public void Execute(IConsoleShell shell, string argStr, string[] args)
- {
- var cfg = IoCManager.Resolve<IConfigurationManager>();
+ [Dependency] private readonly IConfigurationManager _configManager = default!;
+
+ public override string Command => "setlooc";
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
+ {
if (args.Length > 1)
{
- shell.WriteError(Loc.GetString("set-looc-command-too-many-arguments-error"));
+ shell.WriteError(Loc.GetString("shell-need-between-arguments", ("lower", 0), ("upper", 1)));
return;
}
- var looc = cfg.GetCVar(CCVars.LoocEnabled);
+ var looc = _configManager.GetCVar(CCVars.LoocEnabled);
if (args.Length == 0)
{
if (args.Length == 1 && !bool.TryParse(args[0], out looc))
{
- shell.WriteError(Loc.GetString("set-looc-command-invalid-argument-error"));
+ shell.WriteError(Loc.GetString("shell-invalid-bool"));
return;
}
- cfg.SetCVar(CCVars.LoocEnabled, looc);
+ _configManager.SetCVar(CCVars.LoocEnabled, looc);
- shell.WriteLine(Loc.GetString(looc ? "set-looc-command-looc-enabled" : "set-looc-command-looc-disabled"));
+ shell.WriteLine(Loc.GetString(looc ? "cmd-setlooc-looc-enabled" : "cmd-setlooc-looc-disabled"));
}
}
namespace Content.Server.Chat.Commands;
[AdminCommand(AdminFlags.Admin)]
-public sealed class SetOOCCommand : IConsoleCommand
+public sealed class SetOOCCommand : LocalizedCommands
{
- public string Command => "setooc";
- public string Description => Loc.GetString("set-ooc-command-description");
- public string Help => Loc.GetString("set-ooc-command-help");
- public void Execute(IConsoleShell shell, string argStr, string[] args)
- {
- var cfg = IoCManager.Resolve<IConfigurationManager>();
+ [Dependency] private readonly IConfigurationManager _configManager = default!;
+
+ public override string Command => "setooc";
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
+ {
if (args.Length > 1)
{
- shell.WriteError(Loc.GetString("set-ooc-command-too-many-arguments-error"));
+ shell.WriteError(Loc.GetString("shell-need-between-arguments", ("lower", 0), ("upper", 1)));
return;
}
- var ooc = cfg.GetCVar(CCVars.OocEnabled);
+ var ooc = _configManager.GetCVar(CCVars.OocEnabled);
if (args.Length == 0)
{
if (args.Length == 1 && !bool.TryParse(args[0], out ooc))
{
- shell.WriteError(Loc.GetString("set-ooc-command-invalid-argument-error"));
+ shell.WriteError(Loc.GetString("shell-invalid-bool"));
return;
}
- cfg.SetCVar(CCVars.OocEnabled, ooc);
+ _configManager.SetCVar(CCVars.OocEnabled, ooc);
- shell.WriteLine(Loc.GetString(ooc ? "set-ooc-command-ooc-enabled" : "set-ooc-command-ooc-disabled"));
+ shell.WriteLine(Loc.GetString(ooc ? "cmd-setooc-ooc-enabled" : "cmd-setooc-ooc-disabled"));
}
}
namespace Content.Server.Chat.Commands
{
[AnyCommand]
- internal sealed class WhisperCommand : IConsoleCommand
+ internal sealed class WhisperCommand : LocalizedEntityCommands
{
- public string Command => "whisper";
- public string Description => "Send chat messages to the local channel as a whisper";
- public string Help => "whisper <text>";
+ [Dependency] private readonly ChatSystem _chatSystem = default!;
+ public override string Command => "whisper";
- public void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player is not { } player)
{
if (player.AttachedEntity is not {} playerEntity)
{
- shell.WriteError("You don't have an entity!");
+ shell.WriteError(Loc.GetString($"shell-must-be-attached-to-entity"));
return;
}
if (string.IsNullOrEmpty(message))
return;
- IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ChatSystem>()
- .TrySendInGameICMessage(playerEntity, message, InGameICChatType.Whisper, ChatTransmitRange.Normal, false, shell, player);
+ _chatSystem.TrySendInGameICMessage(playerEntity, message, InGameICChatType.Whisper, ChatTransmitRange.Normal, false, shell, player);
}
}
}
namespace Content.Server.EntityList
{
[AdminCommand(AdminFlags.Spawn)]
- public sealed class SpawnEntityListCommand : IConsoleCommand
+ public sealed class SpawnEntityListCommand : LocalizedEntityCommands
{
- public string Command => "spawnentitylist";
- public string Description => "Spawns a list of entities around you";
- public string Help => $"Usage: {Command} <entityListPrototypeId>";
+ [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
- public void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override string Command => "spawnentitylist";
+
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1)
{
- shell.WriteError($"Invalid arguments.\n{Help}");
+ shell.WriteError(Loc.GetString($"shell-need-exactly-one-argument"));
return;
}
return;
}
- var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
-
- if (!prototypeManager.TryIndex(args[0], out EntityListPrototype? prototype))
+ if (!_prototypeManager.TryIndex(args[0], out EntityListPrototype? prototype))
{
- shell.WriteError($"No {nameof(EntityListPrototype)} found with id {args[0]}");
+ shell.WriteError(Loc.GetString($"cmd-spawnentitylist-failed",
+ ("prototype", nameof(EntityListPrototype)),
+ ("id", args[0])));
return;
}
- var entityManager = IoCManager.Resolve<IEntityManager>();
var i = 0;
- foreach (var entity in prototype.Entities(prototypeManager))
+ foreach (var entity in prototype.Entities(_prototypeManager))
{
- entityManager.SpawnEntity(entity.ID, entityManager.GetComponent<TransformComponent>(attached).Coordinates);
+ EntityManager.SpawnEntity(entity.ID, EntityManager.GetComponent<TransformComponent>(attached).Coordinates);
i++;
}
- shell.WriteLine($"Spawned {i} entities.");
+ shell.WriteLine(Loc.GetString($"cmd-spawnentitylist-success", ("count", i)));
}
}
}
namespace Content.Server.GameTicking.Commands
{
[AdminCommand(AdminFlags.Round)]
- sealed class ToggleDisallowLateJoinCommand : IConsoleCommand
+ public sealed class ToggleDisallowLateJoinCommand : LocalizedCommands
{
- public string Command => "toggledisallowlatejoin";
- public string Description => "Allows or disallows latejoining during mid-game.";
- public string Help => $"Usage: {Command} <disallow>";
+ [Dependency] private readonly IConfigurationManager _configManager = default!;
- public void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override string Command => "toggledisallowlatejoin";
+
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1)
{
- shell.WriteLine("Need exactly one argument.");
+ shell.WriteLine(Loc.GetString($"shell-need-exactly-one-argument"));
return;
}
- var cfgMan = IoCManager.Resolve<IConfigurationManager>();
-
if (bool.TryParse(args[0], out var result))
{
- cfgMan.SetCVar(CCVars.GameDisallowLateJoins, bool.Parse(args[0]));
- shell.WriteLine(result ? "Late joining has been disabled." : "Late joining has been enabled.");
+ _configManager.SetCVar(CCVars.GameDisallowLateJoins, bool.Parse(args[0]));
+ shell.WriteLine(Loc.GetString(result ? "cmd-toggledisallowlatejoin-disabled" : "cmd-toggledisallowlatejoin-enabled"));
}
else
- {
- shell.WriteLine("Invalid argument.");
- }
+ shell.WriteLine(Loc.GetString($"shell-invalid-bool"));
}
}
}
-set-looc-command-description = Allows you to enable or disable LOOC.
-set-looc-command-help = Usage: setlooc OR setlooc [value]
-set-looc-command-too-many-arguments-error = Too many arguments.
-set-looc-command-invalid-argument-error = Invalid argument.
-set-looc-command-looc-enabled = LOOC chat has been enabled.
-set-looc-command-looc-disabled = LOOC chat has been disabled.
+cmd-setlooc-description = Allows you to enable or disable LOOC.
+cmd-setlooc-help = Usage: setlooc OR setlooc [value]
+cmd-setlooc-looc-enabled = LOOC chat has been enabled.
+cmd-setlooc-looc-disabled = LOOC chat has been disabled.
-set-ooc-command-description = Allows you to enable or disable OOC.
-set-ooc-command-help = Usage: setooc OR setooc [value]
-set-ooc-command-too-many-arguments-error = Too many arguments.
-set-ooc-command-invalid-argument-error = Invalid argument.
-set-ooc-command-ooc-enabled = OOC chat has been enabled.
-set-ooc-command-ooc-disabled = OOC chat has been disabled.
+cmd-setooc-desc = Allows you to enable or disable OOC.
+cmd-setooc-help = Usage: setooc OR setooc [value]
+cmd-setooc-ooc-enabled = OOC chat has been enabled.
+cmd-setooc-ooc-disabled = OOC chat has been disabled.
--- /dev/null
+cmd-asay-desc = Send chat messages to the private admin chat channel.
+cmd-asay-help = Usage: asay <text>
--- /dev/null
+cmd-me-desc = Perform an action.
+cmd-me-help = Usage: me <text>
--- /dev/null
+cmd-ooc-desc = Send Out Of Character chat messages.
+cmd-ooc-help = Usage: ooc <text>
--- /dev/null
+cmd-say-desc = Send chat messages to the local channel or a specified radio channel.
+cmd-say-help = Usage: say <text>
--- /dev/null
+cmd-spawnentitylist-desc = Spawns a list of entities around you.
+cmd-spawnentitylist-help = Usage: spawnentitylist <entityListPrototypeId>
+cmd-spawnentitylist-failed = No {$prototype} found with id {$id},
+cmd-spawnentitylist-success = Spawned {$count} entities.
--- /dev/null
+cmd-toggledisallowlatejoin-desc = Allows or disallows latejoining during mid-game.
+cmd-toggledisallowlatejoin-help = Usage: toggledisallowlatejoin <disallow>
+cmd-toggledisallowlatejoin-disabled = Late joining has been disabled.
+cmd-toggledisallowlatejoin-enabled = Late joining has been enabled.
--- /dev/null
+cmd-whisper-desc = Send chat messages to the local channel as a whisper.
+cmd-whisper-help = Usage: whisper <text>