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:
@@ -2,8 +2,8 @@ using Content.Server.GameObjects.Components.Mobs;
|
||||
using Content.Server.GameObjects.Components.Observer;
|
||||
using Content.Server.Players;
|
||||
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,23 +12,24 @@ using Robust.Shared.Localization;
|
||||
namespace Content.Server.Administration.Commands
|
||||
{
|
||||
[AdminCommand(AdminFlags.Admin)]
|
||||
class ControlMob : IClientCommand
|
||||
class ControlMob : IConsoleCommand
|
||||
{
|
||||
public string Command => "controlmob";
|
||||
public string Description => Loc.GetString("Transfers user mind to the specified entity.");
|
||||
public string Help => Loc.GetString("Usage: controlmob <mobUid>.");
|
||||
|
||||
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 == null)
|
||||
{
|
||||
shell.SendText((IPlayerSession) null, "Server cannot do this.");
|
||||
shell.WriteLine("Server cannot do this.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Length != 1)
|
||||
{
|
||||
shell.SendText(player, Loc.GetString("Wrong number of arguments."));
|
||||
shell.WriteLine(Loc.GetString("Wrong number of arguments."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -38,7 +39,7 @@ namespace Content.Server.Administration.Commands
|
||||
|
||||
if (!int.TryParse(args[0], out var targetId))
|
||||
{
|
||||
shell.SendText(player, Loc.GetString("Argument must be a number."));
|
||||
shell.WriteLine(Loc.GetString("Argument must be a number."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -46,14 +47,14 @@ namespace Content.Server.Administration.Commands
|
||||
|
||||
if (!eUid.IsValid() || !entityManager.EntityExists(eUid))
|
||||
{
|
||||
shell.SendText(player, Loc.GetString("Invalid entity ID."));
|
||||
shell.WriteLine(Loc.GetString("Invalid entity ID."));
|
||||
return;
|
||||
}
|
||||
|
||||
var target = entityManager.GetEntity(eUid);
|
||||
if (!target.TryGetComponent(out MindComponent mindComponent))
|
||||
{
|
||||
shell.SendText(player, Loc.GetString("Target entity is not a mob!"));
|
||||
shell.WriteLine(Loc.GetString("Target entity is not a mob!"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user