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,8 +1,8 @@
using Content.Server.Administration;
using Content.Server.Administration;
using Content.Shared.Administration;
using Content.Shared.Maps;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects.Components.Transform;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map;
@@ -12,15 +12,16 @@ using Robust.Shared.Map;
namespace Content.Server.Commands.GameTicking
{
[AdminCommand(AdminFlags.Mapping)]
class TileWallsCommand : IClientCommand
class TileWallsCommand : IConsoleCommand
{
// ReSharper disable once StringLiteralTypo
public string Command => "tilewalls";
public string Description => "Puts an underplating tile below every wall on a grid.";
public string Help => $"Usage: {Command} <gridId> | {Command}";
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args)
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
GridId gridId;
switch (args.Length)
@@ -28,7 +29,7 @@ namespace Content.Server.Commands.GameTicking
case 0:
if (player?.AttachedEntity == null)
{
shell.SendText((IPlayerSession) null, "Only a player can run this command.");
shell.WriteLine("Only a player can run this command.");
return;
}
@@ -37,28 +38,28 @@ namespace Content.Server.Commands.GameTicking
case 1:
if (!int.TryParse(args[0], out var id))
{
shell.SendText(player, $"{args[0]} is not a valid integer.");
shell.WriteLine($"{args[0]} is not a valid integer.");
return;
}
gridId = new GridId(id);
break;
default:
shell.SendText(player, Help);
shell.WriteLine(Help);
return;
}
var mapManager = IoCManager.Resolve<IMapManager>();
if (!mapManager.TryGetGrid(gridId, out var grid))
{
shell.SendText(player, $"No grid exists with id {gridId}");
shell.WriteLine($"No grid exists with id {gridId}");
return;
}
var entityManager = IoCManager.Resolve<IEntityManager>();
if (!entityManager.TryGetEntity(grid.GridEntityId, out var gridEntity))
{
shell.SendText(player, $"Grid {gridId} doesn't have an associated grid entity.");
shell.WriteLine($"Grid {gridId} doesn't have an associated grid entity.");
return;
}
@@ -106,7 +107,7 @@ namespace Content.Server.Commands.GameTicking
changed++;
}
shell.SendText(player, $"Changed {changed} tiles.");
shell.WriteLine($"Changed {changed} tiles.");
}
}
}