Console Unify API Changes (#3059)

* Remove unused IChatCommand.

* Lots of refactoring into a shared context.

* Removed ICommonSession from server concmd Execute.

* Added argStr parameter to concmd execute.

* The execute function of client concmds now returns void, use the new shell.RemoteExecuteCommand function to forward commands.

* Finally move shells and commands into shared.

* Console commands can now be registered directly without a class in a shared context.

* Engine API Changes.

* Repair rebase damage.

* Update Submodule.
This commit is contained in:
Acruid
2021-02-01 16:49:43 -08:00
committed by GitHub
parent 80ad2ef5b7
commit 8b5d66050a
119 changed files with 820 additions and 796 deletions

View File

@@ -1,9 +1,9 @@
#nullable enable
#nullable enable
using Content.Server.Administration;
using Content.Server.GameObjects.Components.Disposal;
using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
@@ -12,42 +12,43 @@ using Robust.Shared.Localization;
namespace Content.Server.Commands.Disposal
{
[AdminCommand(AdminFlags.Debug)]
public class TubeConnectionsCommand : IClientCommand
public class TubeConnectionsCommand : IConsoleCommand
{
public string Command => "tubeconnections";
public string Description => Loc.GetString("Shows all the directions that a tube can connect in.");
public string Help => $"Usage: {Command} <entityUid>";
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args)
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player?.AttachedEntity == null)
{
shell.SendText(player, Loc.GetString("Only players can use this command"));
shell.WriteLine(Loc.GetString("Only players can use this command"));
return;
}
if (args.Length < 1)
{
shell.SendText(player, Help);
shell.WriteLine(Help);
return;
}
if (!EntityUid.TryParse(args[0], out var id))
{
shell.SendText(player, Loc.GetString("{0} isn't a valid entity uid", args[0]));
shell.WriteLine(Loc.GetString("{0} isn't a valid entity uid", args[0]));
return;
}
var entityManager = IoCManager.Resolve<IEntityManager>();
if (!entityManager.TryGetEntity(id, out var entity))
{
shell.SendText(player, Loc.GetString("No entity exists with uid {0}", id));
shell.WriteLine(Loc.GetString("No entity exists with uid {0}", id));
return;
}
if (!entity.TryGetComponent(out IDisposalTubeComponent? tube))
{
shell.SendText(player, Loc.GetString("Entity with uid {0} doesn't have a {1} component", id, nameof(IDisposalTubeComponent)));
shell.WriteLine(Loc.GetString("Entity with uid {0} doesn't have a {1} component", id, nameof(IDisposalTubeComponent)));
return;
}