Command resolve mega pr batch 5 (#38389)
* commit progress * requested changes
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using Content.Server.Players;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Mind;
|
||||
using Content.Shared.Mind.Components;
|
||||
@@ -9,17 +8,16 @@ using Robust.Shared.Console;
|
||||
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)
|
||||
{
|
||||
@@ -33,7 +31,7 @@ namespace Content.Server.Administration.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
bool ghostOverride = true;
|
||||
var ghostOverride = true;
|
||||
if (args.Length > 2)
|
||||
{
|
||||
ghostOverride = bool.Parse(args[2]);
|
||||
@@ -41,19 +39,19 @@ namespace Content.Server.Administration.Commands
|
||||
|
||||
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;
|
||||
@@ -63,24 +61,21 @@ namespace Content.Server.Administration.Commands
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user