namespace Content.Server.Administration.Commands
{
[UsedImplicitly]
- public sealed class PromoteHostCommand : IConsoleCommand
+ public sealed class PromoteHostCommand : LocalizedCommands
{
- public string Command => "promotehost";
- public string Description => "Grants client temporary full host admin privileges. Use this to bootstrap admins.";
- public string Help => "Usage promotehost <player>";
+ [Dependency] private readonly IAdminManager _adminManager = default!;
+ [Dependency] private readonly IPlayerManager _playerManager = default!;
- public void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override string Command => "promotehost";
+
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1)
{
- shell.WriteLine("Expected exactly one argument.");
+ shell.WriteLine(Loc.GetString($"shell-need-exactly-one-argument"));
return;
}
- var plyMgr = IoCManager.Resolve<IPlayerManager>();
- if (!plyMgr.TryGetSessionByUsername(args[0], out var targetPlayer))
+ if (!_playerManager.TryGetSessionByUsername(args[0], out var targetPlayer))
{
- shell.WriteLine("Unable to find a player by that name.");
+ shell.WriteLine(Loc.GetString($"shell-target-player-does-not-exist"));
return;
}
- var adminMgr = IoCManager.Resolve<IAdminManager>();
- adminMgr.PromoteHost(targetPlayer);
+ _adminManager.PromoteHost(targetPlayer);
}
}
}
namespace Content.Server.Administration.Commands
{
[AnyCommand]
- public sealed class ReAdminCommand : IConsoleCommand
+ public sealed class ReAdminCommand : LocalizedCommands
{
- public string Command => "readmin";
- public string Description => "Re-admins you if you previously de-adminned.";
- public string Help => "Usage: readmin";
+ [Dependency] private readonly IAdminManager _adminManager = default!;
- public void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override string Command => "readmin";
+
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player;
if (player == null)
{
- shell.WriteLine("You cannot use this command from the server console.");
+ shell.WriteLine(Loc.GetString($"shell-cannot-run-command-from-server"));
return;
}
- var mgr = IoCManager.Resolve<IAdminManager>();
-
- if (mgr.GetAdminData(player, includeDeAdmin: true) == null)
+ if (_adminManager.GetAdminData(player, includeDeAdmin: true) == null)
{
- shell.WriteLine("You're not an admin.");
+ shell.WriteLine(Loc.GetString($"cmd-readmin-not-an-admin"));
return;
}
- mgr.ReAdmin(player);
+ _adminManager.ReAdmin(player);
}
}
}
namespace Content.Server.Administration.Commands
{
[AdminCommand(AdminFlags.Mapping)]
- public sealed class RemoveExtraComponents : IConsoleCommand
+ public sealed class RemoveExtraComponents : LocalizedEntityCommands
{
- public string Command => "removeextracomponents";
- public string Description => "Removes all components from all entities of the specified id if that component is not in its prototype.\nIf no id is specified, it matches all entities.";
- public string Help => $"{Command} <entityId> / {Command}";
- public void Execute(IConsoleShell shell, string argStr, string[] args)
+ [Dependency] private readonly IComponentFactory _compFactory = default!;
+ [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
+
+ public override string Command => "removeextracomponents";
+
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
var id = args.Length == 0 ? null : string.Join(" ", args);
- var entityManager = IoCManager.Resolve<IEntityManager>();
- var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
- var fac = IoCManager.Resolve<IComponentFactory>();
EntityPrototype? prototype = null;
var checkPrototype = !string.IsNullOrEmpty(id);
- if (checkPrototype && !prototypeManager.TryIndex(id!, out prototype))
+ if (checkPrototype && !_prototypeManager.TryIndex(id!, out prototype))
{
- shell.WriteError($"Can't find entity prototype with id \"{id}\"!");
+ shell.WriteError(Loc.GetString($"cmd-removeextracomponents-invalid-prototype-id", ("id", $"{id}")));
return;
}
var entities = 0;
var components = 0;
- foreach (var entity in entityManager.GetEntities())
+ foreach (var entity in EntityManager.GetEntities())
{
- var metaData = entityManager.GetComponent<MetaDataComponent>(entity);
+ var metaData = EntityManager.GetComponent<MetaDataComponent>(entity);
if (checkPrototype && metaData.EntityPrototype != prototype || metaData.EntityPrototype == null)
- {
continue;
- }
var modified = false;
- foreach (var component in entityManager.GetComponents(entity))
+ foreach (var component in EntityManager.GetComponents(entity))
{
- if (metaData.EntityPrototype.Components.ContainsKey(fac.GetComponentName(component.GetType())))
+ if (metaData.EntityPrototype.Components.ContainsKey(_compFactory.GetComponentName(component.GetType())))
continue;
- entityManager.RemoveComponent(entity, component);
+ EntityManager.RemoveComponent(entity, component);
components++;
modified = true;
entities++;
}
- shell.WriteLine($"Removed {components} components from {entities} entities{(id == null ? "." : $" with id {id}")}");
+ if (id != null)
+ {
+ shell.WriteLine(Loc.GetString($"cmd-removeextracomponents-success-with-id",
+ ("count", components),
+ ("entities", entities),
+ ("id", id)));
+ return;
+ }
+
+ shell.WriteLine(Loc.GetString($"cmd-removeextracomponents-success",
+ ("count", components),
+ ("entities", entities)));
}
}
}
namespace Content.Server.Administration.Commands;
[AdminCommand(AdminFlags.Ban)]
-public sealed class RoleUnbanCommand : IConsoleCommand
+public sealed class RoleUnbanCommand : LocalizedCommands
{
- public string Command => "roleunban";
- public string Description => Loc.GetString("cmd-roleunban-desc");
- public string Help => Loc.GetString("cmd-roleunban-help");
+ [Dependency] private readonly IBanManager _banManager = default!;
- public async void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override string Command => "roleunban";
+
+ public override async void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1)
{
if (!int.TryParse(args[0], out var banId))
{
- shell.WriteLine($"Unable to parse {args[0]} as a ban id integer.\n{Help}");
+ shell.WriteLine(Loc.GetString($"cmd-roleunban-unable-to-parse-id", ("id", args[0]), ("help", Help)));
return;
}
- var banManager = IoCManager.Resolve<IBanManager>();
- var response = await banManager.PardonRoleBan(banId, shell.Player?.UserId, DateTimeOffset.Now);
+ var response = await _banManager.PardonRoleBan(banId, shell.Player?.UserId, DateTimeOffset.Now);
shell.WriteLine(response);
}
- public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
+ public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
// Can't think of good way to do hint options for this
return args.Length switch
namespace Content.Server.Administration.Commands
{
[AdminCommand(AdminFlags.NameColor)]
- internal sealed class SetAdminOOC : IConsoleCommand
+ internal sealed class SetAdminOOC : LocalizedCommands
{
- public string Command => "setadminooc";
- public string Description => Loc.GetString("set-admin-ooc-command-description", ("command", Command));
- public string Help => Loc.GetString("set-admin-ooc-command-help-text", ("command", Command));
+ [Dependency] private readonly IServerDbManager _dbManager = default!;
+ [Dependency] private readonly IServerPreferencesManager _preferenceManager = default!;
- public void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override string Command => "setadminooc";
+
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player == null)
{
var userId = shell.Player.UserId;
// Save the DB
- var dbMan = IoCManager.Resolve<IServerDbManager>();
- dbMan.SaveAdminOOCColorAsync(userId, color.Value);
+ _dbManager.SaveAdminOOCColorAsync(userId, color.Value);
// Update the cached preference
- var prefManager = IoCManager.Resolve<IServerPreferencesManager>();
- var prefs = prefManager.GetPreferences(userId);
+ var prefs = _preferenceManager.GetPreferences(userId);
prefs.AdminOOCColor = color.Value;
}
}
-using Content.Server.Players;
using Content.Shared.Administration;
using Content.Shared.Mind;
using Content.Shared.Mind.Components;
namespace Content.Server.Administration.Commands
{
[AdminCommand(AdminFlags.Admin)]
- sealed class SetMindCommand : IConsoleCommand
+ public sealed class SetMindCommand : LocalizedEntityCommands
{
- [Dependency] private readonly IEntityManager _entManager = default!;
+ [Dependency] private readonly IPlayerManager _playerManager = default!;
+ [Dependency] private readonly SharedMindSystem _mindSystem = default!;
- public string Command => "setmind";
+ public override string Command => "setmind";
- public string Description => Loc.GetString("set-mind-command-description", ("requiredComponent", nameof(MindContainerComponent)));
+ public override string Description => Loc.GetString("cmd-setmind-desc", ("requiredComponent", nameof(MindContainerComponent)));
- public string Help => Loc.GetString("set-mind-command-help-text", ("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)
{
return;
}
- bool ghostOverride = true;
+ var ghostOverride = true;
if (args.Length > 2)
{
ghostOverride = bool.Parse(args[2]);
var nent = new NetEntity(entInt);
- if (!_entManager.TryGetEntity(nent, out var eUid))
+ if (!EntityManager.TryGetEntity(nent, out var eUid))
{
shell.WriteLine(Loc.GetString("shell-invalid-entity-id"));
return;
}
- if (!_entManager.HasComponent<MindContainerComponent>(eUid))
+ if (!EntityManager.HasComponent<MindContainerComponent>(eUid))
{
- shell.WriteLine(Loc.GetString("set-mind-command-target-has-no-mind-message"));
+ shell.WriteLine(Loc.GetString("cmd-setmind-target-has-no-mind-message"));
return;
}
- if (!IoCManager.Resolve<IPlayerManager>().TryGetSessionByUsername(args[1], out var session))
+ if (!_playerManager.TryGetSessionByUsername(args[1], out var session))
{
shell.WriteLine(Loc.GetString("shell-target-player-does-not-exist"));
return;
var playerCData = session.ContentData();
if (playerCData == null)
{
- shell.WriteLine(Loc.GetString("set-mind-command-target-has-no-content-data-message"));
+ shell.WriteLine(Loc.GetString("cmd-setmind-target-has-no-content-data-message"));
return;
}
- var mindSystem = _entManager.System<SharedMindSystem>();
- var metadata = _entManager.GetComponent<MetaDataComponent>(eUid.Value);
+ var metadata = EntityManager.GetComponent<MetaDataComponent>(eUid.Value);
- var mind = playerCData.Mind ?? mindSystem.CreateMind(session.UserId, metadata.EntityName);
+ var mind = playerCData.Mind ?? _mindSystem.CreateMind(session.UserId, metadata.EntityName);
- mindSystem.TransferTo(mind, eUid, ghostOverride);
+ _mindSystem.TransferTo(mind, eUid, ghostOverride);
}
- public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
+ public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
if (args.Length == 2)
- {
- return CompletionResult.FromHintOptions(CompletionHelper.SessionNames(), Loc.GetString("cmd-mind-command-hint"));
- }
+ return CompletionResult.FromHintOptions(CompletionHelper.SessionNames(), Help);
return CompletionResult.Empty;
}
namespace Content.Server.Administration.Commands
{
[AdminCommand(AdminFlags.Round)]
- public sealed class CallShuttleCommand : IConsoleCommand
+ public sealed class CallShuttleCommand : LocalizedEntityCommands
{
- [Dependency] private readonly IEntityManager _e = default!;
+ [Dependency] private readonly RoundEndSystem _roundEndSystem = default!;
- public string Command => "callshuttle";
- public string Description => Loc.GetString("call-shuttle-command-description");
- public string Help => Loc.GetString("call-shuttle-command-help-text", ("command",Command));
+ public override string Command => "callshuttle";
- public void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
- var loc = IoCManager.Resolve<ILocalizationManager>();
-
// ReSharper disable once ConvertIfStatementToSwitchStatement
- if (args.Length == 1 && TimeSpan.TryParseExact(args[0], ContentLocalizationManager.TimeSpanMinutesFormats, loc.DefaultCulture, out var timeSpan))
- {
- _e.System<RoundEndSystem>().RequestRoundEnd(timeSpan, shell.Player?.AttachedEntity, false);
- }
+ if (args.Length == 1 && TimeSpan.TryParseExact(args[0], ContentLocalizationManager.TimeSpanMinutesFormats, LocalizationManager.DefaultCulture, out var timeSpan))
+ _roundEndSystem.RequestRoundEnd(timeSpan, shell.Player?.AttachedEntity, false);
+
else if (args.Length == 1)
- {
shell.WriteLine(Loc.GetString("shell-timespan-minutes-must-be-correct"));
- }
+
else
- {
- _e.System<RoundEndSystem>().RequestRoundEnd(shell.Player?.AttachedEntity, false);
- }
+ _roundEndSystem.RequestRoundEnd(shell.Player?.AttachedEntity, false);
}
}
[AdminCommand(AdminFlags.Round)]
- public sealed class RecallShuttleCommand : IConsoleCommand
+ public sealed class RecallShuttleCommand : LocalizedEntityCommands
{
- [Dependency] private readonly IEntityManager _e = default!;
+ [Dependency] private readonly RoundEndSystem _roundEndSystem = default!;
- public string Command => "recallshuttle";
- public string Description => Loc.GetString("recall-shuttle-command-description");
- public string Help => Loc.GetString("recall-shuttle-command-help-text", ("command",Command));
+ public override string Command => "recallshuttle";
- public void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
- _e.System<RoundEndSystem>().CancelRoundEndCountdown(shell.Player?.AttachedEntity, false);
+ _roundEndSystem.CancelRoundEndCountdown(shell.Player?.AttachedEntity, false);
}
}
}
namespace Content.Server.Afk
{
[AdminCommand(AdminFlags.Admin)]
- public sealed class IsAfkCommand : IConsoleCommand
+ public sealed class IsAfkCommand : LocalizedCommands
{
+ [Dependency] private readonly IAfkManager _afkManager = default!;
[Dependency] private readonly IPlayerManager _players = default!;
- public string Command => "isafk";
- public string Description => "Checks if a specified player is AFK";
- public string Help => "Usage: isafk <playerName>";
+ public override string Command => "isafk";
- public void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
- var afkManager = IoCManager.Resolve<IAfkManager>();
-
if (args.Length == 0)
{
- shell.WriteError("Need one argument");
+ shell.WriteError(Loc.GetString($"shell-need-exactly-one-argument"));
return;
}
if (!_players.TryGetSessionByUsername(args[0], out var player))
{
- shell.WriteError("Unable to find that player");
+ shell.WriteError(Loc.GetString($"shell-target-player-does-not-exist"));
return;
}
- shell.WriteLine(afkManager.IsAfk(player) ? "They are indeed AFK" : "They are not AFK");
+ shell.WriteLine(Loc.GetString(_afkManager.IsAfk(player) ? "cmd-isafk-true" : "cmd-isafk-false"));
}
- public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
+ public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
if (args.Length == 1)
{
using Content.Shared.Administration;
using Content.Shared.Body.Components;
using Robust.Shared.Console;
-using Robust.Shared.Random;
namespace Content.Server.Body.Commands
{
[AdminCommand(AdminFlags.Fun)]
- sealed class DestroyMechanismCommand : IConsoleCommand
+ internal sealed class DestroyMechanismCommand : LocalizedEntityCommands
{
- public string Command => "destroymechanism";
- public string Description => "Destroys a mechanism from your entity";
- public string Help => $"Usage: {Command} <mechanism>";
+ [Dependency] private readonly IComponentFactory _compFactory = default!;
+ [Dependency] private readonly BodySystem _bodySystem = default!;
- public void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override string Command => "destroymechanism";
+
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player;
if (player == null)
{
- shell.WriteLine("Only a player can run this command.");
+ shell.WriteLine(Loc.GetString($"shell-only-players-can-run-this-command"));
return;
}
if (player.AttachedEntity is not {} attached)
{
- shell.WriteLine("You have no entity.");
+ shell.WriteLine(Loc.GetString($"shell-must-be-attached-to-entity"));
return;
}
- var entityManager = IoCManager.Resolve<IEntityManager>();
- var fac = IoCManager.Resolve<IComponentFactory>();
-
- if (!entityManager.TryGetComponent(attached, out BodyComponent? body))
+ if (!EntityManager.TryGetComponent(attached, out BodyComponent? body))
{
- var random = IoCManager.Resolve<IRobustRandom>();
- var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}";
-
- shell.WriteLine(text);
+ shell.WriteLine(Loc.GetString($"shell-must-have-body"));
return;
}
var mechanismName = string.Join(" ", args).ToLowerInvariant();
- var bodySystem = entityManager.System<BodySystem>();
- foreach (var organ in bodySystem.GetBodyOrgans(attached, body))
+ foreach (var organ in _bodySystem.GetBodyOrgans(attached, body))
{
- if (fac.GetComponentName(organ.Component.GetType()).ToLowerInvariant() == mechanismName)
+ if (_compFactory.GetComponentName(organ.Component.GetType()).ToLowerInvariant() == mechanismName)
{
- entityManager.QueueDeleteEntity(organ.Id);
- shell.WriteLine($"Mechanism with name {mechanismName} has been destroyed.");
+ EntityManager.QueueDeleteEntity(organ.Id);
+ shell.WriteLine(Loc.GetString($"cmd-destroymechanism-success", ("name", mechanismName)));
return;
}
}
- shell.WriteLine($"No mechanism was found with name {mechanismName}.");
+ shell.WriteLine(Loc.GetString($"cmd-destroymechanism-no-mechanism-found", ("name", mechanismName)));
}
}
}
-call-shuttle-command-description = Calls the emergency shuttle with an optionally provided arrival time.
-call-shuttle-command-help-text = Usage: {$command} [m:ss]
-recall-shuttle-command-description = Recalls the emergency shuttle.
-recall-shuttle-command-help-text = Usage: {$command}
+cmd-callshuttle-desc = Calls the emergency shuttle with an optionally provided arrival time.
+cmd-callshuttle-help = Usage: callshuttle [m:ss]
+cmd-recallshuttle-desc = Recalls the emergency shuttle.
+cmd-recallshuttle-help = Usage: recallshuttle
-set-admin-ooc-command-description = Sets the color of your OOC messages. Color must be in hex format, example: {$command} #c43b23
-set-admin-ooc-command-help-text = Usage: {$command} <color>
\ No newline at end of file
+cmd-setadminooc-desc = Sets the color of your OOC messages. Color must be in hex format, example: setadminooc #c43b23
+cmd-setadminooc-help = Usage: setadminooc <color>
-set-mind-command-description = Transfers a mind to the specified entity. The entity must have a {$requiredComponent}. By default this will force minds that are currently visiting other entities to return (i.e., return a ghost to their main body).
-set-mind-command-help-text = Usage: {$command} <entityUid> <username> [unvisit]
-set-mind-command-target-has-no-content-data-message = Target player does not have content data (wtf?)
-set-mind-command-target-has-no-mind-message = Target entity does not have a mind (did you forget to make sentient?)
-cmd-mind-command-hint = username
+cmd-setmind-desc = Transfers a mind to the specified entity. The entity must have a {$requiredComponent}. By default this will force minds that are currently visiting other entities to return (i.e., return a ghost to their main body).
+cmd-setmind-help = Usage: {$command} <entityUid> <username> [unvisit]
+cmd-setmind-command-target-has-no-content-data-message = Target player does not have content data (wtf?)
+cmd-setmind-command-target-has-no-mind-message = Target entity does not have a mind (did you forget to make sentient?)
--- /dev/null
+cmd-destroymechanism-desc = Destroys a mechanism from your entity.
+cmd-destroymechanism-help = Usage: destroymechanism <mechanism>
+cmd-destroymechanism-success = Mechanism with name {$name} has been destroyed.
+cmd-destroymechanism-no-mechanism-found = No mechanism was found with name {$name}.
--- /dev/null
+cmd-isafk-desc = Checks if a specified player is AFK.
+cmd-isafk-help = Usage: isafk <playerName>
+cmd-isafk-true = They are indeed AFK.
+cmd-isafk-false = They are not AFK.
--- /dev/null
+cmd-promotehost-desc = Grants client temporary full host admin privileges. Use this to bootstrap admins.
+cmd-promotehost-help = Usage promotehost <player>
--- /dev/null
+cmd-readmin-desc = Re-admins you if you previously de-adminned.
+cmd-readmin-help = Usage: readmin
+cmd-readmin-not-an-admin = You're not an admin.
--- /dev/null
+cmd-removeextracomponents-desc = Removes all components from all entities of the specified id if that component is not in its prototype.\nIf no id is specified, it matches all entities.
+cmd-removeextracomponents-help = removeextracomponents / removeextracomponents <entityId>
+cmd-removeextracomponents-invalid-prototype-id = Can't find entity prototype with id {$id}.
+cmd-removeextracomponents-success = Removed {$count} components from {$entities},
+cmd-removeextracomponents-success-with-id = Removed {$count} components from {$entities} with id {$id}.
cmd-roleunban-desc = Pardons a player's role ban
cmd-roleunban-help = Usage: roleunban <role ban id>
+cmd-roleunban-unable-to-parse-id = Unable to parse {$id} as a ban id integer.
+ {$help}
## Completion result hints
cmd-roleunban-hint-1 = <role ban id>
shell-cannot-run-command-from-server = You cannot run this command from the server.
shell-only-players-can-run-this-command = Only players can run this command.
shell-must-be-attached-to-entity = You must be attached to an entity to run this command.
+shell-must-have-body = You must have a body to run this command.
## Arguments