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:
@@ -1,11 +1,11 @@
|
||||
#nullable enable
|
||||
#nullable enable
|
||||
using System.Linq;
|
||||
using Content.Server.Administration;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.GameObjects.Components.Body;
|
||||
using Content.Shared.GameObjects.Components.Body.Part;
|
||||
using Robust.Server.Interfaces.Console;
|
||||
using Robust.Server.Interfaces.Player;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.Interfaces.Random;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Random;
|
||||
@@ -13,23 +13,24 @@ using Robust.Shared.Random;
|
||||
namespace Content.Server.Commands.Body
|
||||
{
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
class RemoveHandCommand : IClientCommand
|
||||
class RemoveHandCommand : IConsoleCommand
|
||||
{
|
||||
public string Command => "removehand";
|
||||
public string Description => "Removes a hand from your entity.";
|
||||
public string Help => $"Usage: {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;
|
||||
if (player == null)
|
||||
{
|
||||
shell.SendText(player, "Only a player can run this command.");
|
||||
shell.WriteLine("Only a player can run this command.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.AttachedEntity == null)
|
||||
{
|
||||
shell.SendText(player, "You have no entity.");
|
||||
shell.WriteLine("You have no entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -38,14 +39,14 @@ namespace Content.Server.Commands.Body
|
||||
var random = IoCManager.Resolve<IRobustRandom>();
|
||||
var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}";
|
||||
|
||||
shell.SendText(player, text);
|
||||
shell.WriteLine(text);
|
||||
return;
|
||||
}
|
||||
|
||||
var (_, hand) = body.Parts.FirstOrDefault(x => x.Value.PartType == BodyPartType.Hand);
|
||||
if (hand == null)
|
||||
{
|
||||
shell.SendText(player, "You have no hands.");
|
||||
shell.WriteLine("You have no hands.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user