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

@@ -78,7 +78,7 @@ namespace Content.Client.Chat
private ChatChannel _filteredChannels; private ChatChannel _filteredChannels;
[Dependency] private readonly IClientNetManager _netManager = default!; [Dependency] private readonly IClientNetManager _netManager = default!;
[Dependency] private readonly IClientConsole _console = default!; [Dependency] private readonly IClientConsoleHost _consoleHost = default!;
[Dependency] private readonly IEntityManager _entityManager = default!; [Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!; [Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!; [Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
@@ -255,7 +255,7 @@ namespace Content.Client.Chat
{ {
// run locally // run locally
var conInput = text.Substring(1); var conInput = text.Substring(1);
_console.ProcessCommand(conInput); _consoleHost.ExecuteCommand(conInput);
break; break;
} }
case OOCAlias: case OOCAlias:
@@ -263,7 +263,7 @@ namespace Content.Client.Chat
var conInput = text.Substring(1); var conInput = text.Substring(1);
if (string.IsNullOrWhiteSpace(conInput)) if (string.IsNullOrWhiteSpace(conInput))
return; return;
_console.ProcessCommand($"ooc \"{CommandParsing.Escape(conInput)}\""); _consoleHost.ExecuteCommand($"ooc \"{CommandParsing.Escape(conInput)}\"");
break; break;
} }
case AdminChatAlias: case AdminChatAlias:
@@ -273,11 +273,11 @@ namespace Content.Client.Chat
return; return;
if (_groupController.CanCommand("asay")) if (_groupController.CanCommand("asay"))
{ {
_console.ProcessCommand($"asay \"{CommandParsing.Escape(conInput)}\""); _consoleHost.ExecuteCommand($"asay \"{CommandParsing.Escape(conInput)}\"");
} }
else else
{ {
_console.ProcessCommand($"ooc \"{CommandParsing.Escape(conInput)}\""); _consoleHost.ExecuteCommand($"ooc \"{CommandParsing.Escape(conInput)}\"");
} }
break; break;
@@ -287,7 +287,7 @@ namespace Content.Client.Chat
var conInput = text.Substring(1); var conInput = text.Substring(1);
if (string.IsNullOrWhiteSpace(conInput)) if (string.IsNullOrWhiteSpace(conInput))
return; return;
_console.ProcessCommand($"me \"{CommandParsing.Escape(conInput)}\""); _consoleHost.ExecuteCommand($"me \"{CommandParsing.Escape(conInput)}\"");
break; break;
} }
default: default:
@@ -295,7 +295,7 @@ namespace Content.Client.Chat
var conInput = _currentChatBox?.DefaultChatFormat != null var conInput = _currentChatBox?.DefaultChatFormat != null
? string.Format(_currentChatBox.DefaultChatFormat, CommandParsing.Escape(text)) ? string.Format(_currentChatBox.DefaultChatFormat, CommandParsing.Escape(text))
: text; : text;
_console.ProcessCommand(conInput); _consoleHost.ExecuteCommand(conInput);
break; break;
} }
} }

View File

@@ -4,12 +4,12 @@ using System.Collections.Generic;
using Content.Client.Interfaces; using Content.Client.Interfaces;
using Content.Client.UserInterface.Stylesheets; using Content.Client.UserInterface.Stylesheets;
using Content.Shared; using Content.Shared;
using Robust.Client.Interfaces.Console;
using Robust.Client.Interfaces.Graphics.ClientEye; using Robust.Client.Interfaces.Graphics.ClientEye;
using Robust.Client.Interfaces.Input; using Robust.Client.Interfaces.Input;
using Robust.Client.Interfaces.UserInterface; using Robust.Client.Interfaces.UserInterface;
using Robust.Client.Player; using Robust.Client.Player;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Shared.Console;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Network; using Robust.Shared.Interfaces.Network;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -168,12 +168,11 @@ namespace Content.Client
public string Description => ""; public string Description => "";
public string Help => ""; public string Help => "";
public bool Execute(IDebugConsole console, params string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var arg = args[0]; var arg = args[0];
var mgr = IoCManager.Resolve<IClientNotifyManager>(); var mgr = IoCManager.Resolve<IClientNotifyManager>();
mgr.PopupMessage(arg); mgr.PopupMessage(arg);
return false;
} }
} }
} }

View File

@@ -1,9 +1,9 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.Interfaces.Console;
using Content.Client.GameObjects.EntitySystems; using Content.Client.GameObjects.EntitySystems;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using System; using System;
using Robust.Shared.Console;
namespace Content.Client.Commands namespace Content.Client.Commands
{ {
@@ -13,32 +13,31 @@ namespace Content.Client.Commands
public string Command => "atvrange"; public string Command => "atvrange";
public string Description => "Sets the atmos debug range (as two floats, start [red] and end [blue])"; public string Description => "Sets the atmos debug range (as two floats, start [red] and end [blue])";
public string Help => "atvrange <start> <end>"; public string Help => "atvrange <start> <end>";
public bool Execute(IDebugConsole console, params string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length != 2) if (args.Length != 2)
{ {
console.AddLine(Help); shell.WriteLine(Help);
return false; return;
} }
if (!float.TryParse(args[0], out var xStart)) if (!float.TryParse(args[0], out var xStart))
{ {
console.AddLine("Bad float START"); shell.WriteLine("Bad float START");
return false; return;
} }
if (!float.TryParse(args[1], out var xEnd)) if (!float.TryParse(args[1], out var xEnd))
{ {
console.AddLine("Bad float END"); shell.WriteLine("Bad float END");
return false; return;
} }
if (xStart == xEnd) if (xStart == xEnd)
{ {
console.AddLine("Scale cannot be zero, as this would cause a division by zero in AtmosDebugOverlay."); shell.WriteLine("Scale cannot be zero, as this would cause a division by zero in AtmosDebugOverlay.");
return false; return;
} }
var sys = EntitySystem.Get<AtmosDebugOverlaySystem>(); var sys = EntitySystem.Get<AtmosDebugOverlaySystem>();
sys.CfgBase = xStart; sys.CfgBase = xStart;
sys.CfgScale = xEnd - xStart; sys.CfgScale = xEnd - xStart;
return false;
} }
} }
@@ -48,17 +47,17 @@ namespace Content.Client.Commands
public string Command => "atvmode"; public string Command => "atvmode";
public string Description => "Sets the atmos debug mode. This will automatically reset the scale."; public string Description => "Sets the atmos debug mode. This will automatically reset the scale.";
public string Help => "atvmode <TotalMoles/GasMoles/Temperature> [<gas ID (for GasMoles)>]"; public string Help => "atvmode <TotalMoles/GasMoles/Temperature> [<gas ID (for GasMoles)>]";
public bool Execute(IDebugConsole console, params string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length < 1) if (args.Length < 1)
{ {
console.AddLine(Help); shell.WriteLine(Help);
return false; return;
} }
if (!Enum.TryParse<AtmosDebugOverlayMode>(args[0], out var xMode)) if (!Enum.TryParse<AtmosDebugOverlayMode>(args[0], out var xMode))
{ {
console.AddLine("Invalid mode"); shell.WriteLine("Invalid mode");
return false; return;
} }
int xSpecificGas = 0; int xSpecificGas = 0;
float xBase = 0; float xBase = 0;
@@ -67,21 +66,21 @@ namespace Content.Client.Commands
{ {
if (args.Length != 2) if (args.Length != 2)
{ {
console.AddLine("A target gas must be provided for this mode."); shell.WriteLine("A target gas must be provided for this mode.");
return false; return;
} }
if (!AtmosCommandUtils.TryParseGasID(args[1], out xSpecificGas)) if (!AtmosCommandUtils.TryParseGasID(args[1], out xSpecificGas))
{ {
console.AddLine("Gas ID not parsable or out of range."); shell.WriteLine("Gas ID not parsable or out of range.");
return false; return;
} }
} }
else else
{ {
if (args.Length != 1) if (args.Length != 1)
{ {
console.AddLine("No further information is required for this mode."); shell.WriteLine("No further information is required for this mode.");
return false; return;
} }
if (xMode == AtmosDebugOverlayMode.Temperature) if (xMode == AtmosDebugOverlayMode.Temperature)
{ {
@@ -95,7 +94,6 @@ namespace Content.Client.Commands
sys.CfgSpecificGas = xSpecificGas; sys.CfgSpecificGas = xSpecificGas;
sys.CfgBase = xBase; sys.CfgBase = xBase;
sys.CfgScale = xScale; sys.CfgScale = xScale;
return false;
} }
} }
@@ -105,21 +103,20 @@ namespace Content.Client.Commands
public string Command => "atvcbm"; public string Command => "atvcbm";
public string Description => "Changes from red/green/blue to greyscale"; public string Description => "Changes from red/green/blue to greyscale";
public string Help => "atvcbm <true/false>"; public string Help => "atvcbm <true/false>";
public bool Execute(IDebugConsole console, params string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length != 1) if (args.Length != 1)
{ {
console.AddLine(Help); shell.WriteLine(Help);
return false; return;
} }
if (!bool.TryParse(args[0], out var xFlag)) if (!bool.TryParse(args[0], out var xFlag))
{ {
console.AddLine("Invalid flag"); shell.WriteLine("Invalid flag");
return false; return;
} }
var sys = EntitySystem.Get<AtmosDebugOverlaySystem>(); var sys = EntitySystem.Get<AtmosDebugOverlaySystem>();
sys.CfgCBM = xFlag; sys.CfgCBM = xFlag;
return false;
} }
} }
} }

View File

@@ -1,6 +1,6 @@
using Content.Client.UserInterface; using Content.Client.UserInterface;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.Interfaces.Console; using Robust.Shared.Console;
namespace Content.Client.Commands namespace Content.Client.Commands
{ {
@@ -11,10 +11,9 @@ namespace Content.Client.Commands
public string Description => "Opens the credits window"; public string Description => "Opens the credits window";
public string Help => "credits"; public string Help => "credits";
public bool Execute(IDebugConsole console, params string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
new CreditsWindow().Open(); new CreditsWindow().Open();
return false;
} }
} }
} }

View File

@@ -1,6 +1,6 @@
using Content.Client.GameObjects.EntitySystems.AI; using Content.Client.GameObjects.EntitySystems.AI;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.Interfaces.Console; using Robust.Shared.Console;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
namespace Content.Client.Commands namespace Content.Client.Commands
@@ -16,12 +16,13 @@ namespace Content.Client.Commands
public string Description => "Handles all tooltip debugging above AI mobs"; public string Description => "Handles all tooltip debugging above AI mobs";
public string Help => "debugai [hide/paths/thonk]"; public string Help => "debugai [hide/paths/thonk]";
public bool Execute(IDebugConsole console, params string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
#if DEBUG #if DEBUG
if (args.Length < 1) if (args.Length < 1)
{ {
return true; shell.RemoteExecuteCommand(argStr);
return;
} }
var anyAction = false; var anyAction = false;
@@ -50,9 +51,10 @@ namespace Content.Client.Commands
} }
} }
return !anyAction; if(!anyAction)
shell.RemoteExecuteCommand(argStr);
#else #else
return true; shell.RemoteExecuteCommand(argStr);
#endif #endif
} }
} }

View File

@@ -1,9 +1,10 @@
using System;
using Content.Client.GameObjects.Components; using Content.Client.GameObjects.Components;
using Content.Client.GameObjects.EntitySystems; using Content.Client.GameObjects.EntitySystems;
using Content.Client.Interfaces; using Content.Client.Interfaces;
using Content.Shared.GameObjects; using Content.Shared.GameObjects;
using Robust.Client.Interfaces.Console;
using Robust.Client.Interfaces.GameObjects.Components; using Robust.Client.Interfaces.GameObjects.Components;
using Robust.Shared.Console;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -17,12 +18,10 @@ namespace Content.Client.Commands
public string Description => "Toggles visibility of markers such as spawn points."; public string Description => "Toggles visibility of markers such as spawn points.";
public string Help => ""; public string Help => "";
public bool Execute(IDebugConsole console, params string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
EntitySystem.Get<MarkerSystem>() EntitySystem.Get<MarkerSystem>()
.MarkersVisible ^= true; .MarkersVisible ^= true;
return false;
} }
} }
@@ -33,12 +32,10 @@ namespace Content.Client.Commands
public string Description => "Makes entities below the floor always visible."; public string Description => "Makes entities below the floor always visible.";
public string Help => $"Usage: {Command}"; public string Help => $"Usage: {Command}";
public bool Execute(IDebugConsole console, params string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
EntitySystem.Get<SubFloorHideSystem>() EntitySystem.Get<SubFloorHideSystem>()
.EnableAll ^= true; .EnableAll ^= true;
return false;
} }
} }
@@ -49,7 +46,7 @@ namespace Content.Client.Commands
public string Description => "Makes entities below the floor always visible until the client is restarted."; public string Description => "Makes entities below the floor always visible until the client is restarted.";
public string Help => $"Usage: {Command}"; public string Help => $"Usage: {Command}";
public bool Execute(IDebugConsole console, params string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
EntitySystem.Get<SubFloorHideSystem>() EntitySystem.Get<SubFloorHideSystem>()
.EnableAll = true; .EnableAll = true;
@@ -64,8 +61,6 @@ namespace Content.Client.Commands
sprite.DrawDepth = (int) DrawDepth.Overlays; sprite.DrawDepth = (int) DrawDepth.Overlays;
} }
} }
return false;
} }
} }
@@ -75,14 +70,12 @@ namespace Content.Client.Commands
public string Description => "Send a notify client side."; public string Description => "Send a notify client side.";
public string Help => "notify <message>"; public string Help => "notify <message>";
public bool Execute(IDebugConsole console, params string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var message = args[0]; var message = args[0];
var notifyManager = IoCManager.Resolve<IClientNotifyManager>(); var notifyManager = IoCManager.Resolve<IClientNotifyManager>();
notifyManager.PopupMessage(message); notifyManager.PopupMessage(message);
return false;
} }
} }
@@ -92,18 +85,18 @@ namespace Content.Client.Commands
public string Description => "Creates and teleports you to a new uninitialized map for mapping."; public string Description => "Creates and teleports you to a new uninitialized map for mapping.";
public string Help => $"Usage: {Command} <mapname> / {Command} <id> <mapname>"; public string Help => $"Usage: {Command} <mapname> / {Command} <id> <mapname>";
public bool Execute(IDebugConsole console, params string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length == 0) if (args.Length == 0)
{ {
console.AddLine(Help); shell.WriteLine(Help);
return false; return;
} }
console.Commands["togglelight"].Execute(console); shell.ConsoleHost.RegisteredCommands["togglelight"].Execute(shell, string.Empty, Array.Empty<string>());
console.Commands["showsubfloorforever"].Execute(console); shell.ConsoleHost.RegisteredCommands["showsubfloorforever"].Execute(shell, string.Empty, Array.Empty<string>());
return true; shell.RemoteExecuteCommand(argStr);
} }
} }
} }

View File

@@ -1,6 +1,6 @@
using Content.Client.GameObjects.EntitySystems.AI; using Content.Client.GameObjects.EntitySystems.AI;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.Interfaces.Console; using Robust.Shared.Console;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
namespace Content.Client.Commands namespace Content.Client.Commands
@@ -13,12 +13,13 @@ namespace Content.Client.Commands
public string Description => "Toggles visibility of pathfinding debuggers."; public string Description => "Toggles visibility of pathfinding debuggers.";
public string Help => "pathfinder [hide/nodes/routes/graph/regioncache/regions]"; public string Help => "pathfinder [hide/nodes/routes/graph/regioncache/regions]";
public bool Execute(IDebugConsole console, params string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
#if DEBUG #if DEBUG
if (args.Length < 1) if (args.Length < 1)
{ {
return true; shell.RemoteExecuteCommand(argStr);
return;
} }
var anyAction = false; var anyAction = false;
@@ -63,9 +64,10 @@ namespace Content.Client.Commands
} }
} }
return !anyAction; if(!anyAction)
shell.RemoteExecuteCommand(argStr);
#else #else
return true; shell.RemoteExecuteCommand(argStr);
#endif #endif
} }
} }

View File

@@ -1,7 +1,7 @@
using Content.Shared.GameObjects.Components.Body.Mechanism; using Content.Shared.GameObjects.Components.Body.Mechanism;
using Robust.Client.Console; using Robust.Client.Console;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Client.Interfaces.Console; using Robust.Shared.Console;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -14,7 +14,7 @@ namespace Content.Client.Commands
public string Description => $"Reverts the effects of {ShowMechanismsCommand.CommandName}"; public string Description => $"Reverts the effects of {ShowMechanismsCommand.CommandName}";
public string Help => $"{Command}"; public string Help => $"{Command}";
public bool Execute(IDebugConsole console, params string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var componentManager = IoCManager.Resolve<IComponentManager>(); var componentManager = IoCManager.Resolve<IComponentManager>();
var mechanisms = componentManager.EntityQuery<IMechanism>(); var mechanisms = componentManager.EntityQuery<IMechanism>();
@@ -41,9 +41,7 @@ namespace Content.Client.Commands
} }
} }
IoCManager.Resolve<IClientConsole>().ProcessCommand("hidecontainedcontext"); IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand("hidecontainedcontext");
return false;
} }
} }
} }

View File

@@ -1,7 +1,7 @@
using Content.Shared.GameObjects.Components.Body.Mechanism; using Content.Shared.GameObjects.Components.Body.Mechanism;
using Robust.Client.Console; using Robust.Client.Console;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Client.Interfaces.Console; using Robust.Shared.Console;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -16,7 +16,7 @@ namespace Content.Client.Commands
public string Description => "Makes mechanisms visible, even when they shouldn't be."; public string Description => "Makes mechanisms visible, even when they shouldn't be.";
public string Help => $"{Command}"; public string Help => $"{Command}";
public bool Execute(IDebugConsole console, params string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var componentManager = IoCManager.Resolve<IComponentManager>(); var componentManager = IoCManager.Resolve<IComponentManager>();
var mechanisms = componentManager.EntityQuery<IMechanism>(); var mechanisms = componentManager.EntityQuery<IMechanism>();
@@ -29,9 +29,7 @@ namespace Content.Client.Commands
} }
} }
IoCManager.Resolve<IClientConsole>().ProcessCommand("showcontainedcontext"); IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand("showcontainedcontext");
return false;
} }
} }
} }

View File

@@ -1,5 +1,5 @@
using Content.Shared; using Content.Shared;
using Robust.Client.Interfaces.Console; using Robust.Shared.Console;
using Robust.Shared.Interfaces.Configuration; using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -13,16 +13,14 @@ namespace Content.Client.Commands
public string Help => ""; public string Help => "";
public bool Execute(IDebugConsole console, params string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var configurationManager = IoCManager.Resolve<IConfigurationManager>(); var configurationManager = IoCManager.Resolve<IConfigurationManager>();
var cvar = CCVars.OutlineEnabled; var cvar = CCVars.OutlineEnabled;
var old = configurationManager.GetCVar(cvar); var old = configurationManager.GetCVar(cvar);
configurationManager.SetCVar(cvar, !old); configurationManager.SetCVar(cvar, !old);
console.AddLine($"Draw outlines set to: {configurationManager.GetCVar(cvar)}"); shell.WriteLine($"Draw outlines set to: {configurationManager.GetCVar(cvar)}");
return false;
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using Content.Client.State; using Content.Client.State;
using Content.Client.UserInterface; using Content.Client.UserInterface;
using Robust.Client.Console; using Robust.Client.Console;
using Robust.Client.Interfaces.Input; using Robust.Client.Interfaces.Input;
@@ -12,7 +12,7 @@ namespace Content.Client
{ {
internal sealed class EscapeMenuOwner : IEscapeMenuOwner internal sealed class EscapeMenuOwner : IEscapeMenuOwner
{ {
[Dependency] private readonly IClientConsole _clientConsole = default!; [Dependency] private readonly IClientConsoleHost _consoleHost = default!;
[Dependency] private readonly IInputManager _inputManager = default!; [Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IStateManager _stateManager = default!; [Dependency] private readonly IStateManager _stateManager = default!;
[Dependency] private readonly IGameHud _gameHud = default!; [Dependency] private readonly IGameHud _gameHud = default!;
@@ -31,7 +31,7 @@ namespace Content.Client
if (obj.NewState is GameScreenBase) if (obj.NewState is GameScreenBase)
{ {
// Switched TO GameScreen. // Switched TO GameScreen.
_escapeMenu = new EscapeMenu(_clientConsole); _escapeMenu = new EscapeMenu(_consoleHost);
_escapeMenu.OnClose += () => _gameHud.EscapeButtonDown = false; _escapeMenu.OnClose += () => _gameHud.EscapeButtonDown = false;

View File

@@ -102,7 +102,7 @@ namespace Content.Client.Sandbox
internal class SandboxManager : SharedSandboxManager, ISandboxManager internal class SandboxManager : SharedSandboxManager, ISandboxManager
{ {
[Dependency] private readonly IClientConsole _console = default!; [Dependency] private readonly IClientConsoleHost _consoleHost = default!;
[Dependency] private readonly IGameHud _gameHud = default!; [Dependency] private readonly IGameHud _gameHud = default!;
[Dependency] private readonly IClientNetManager _netManager = default!; [Dependency] private readonly IClientNetManager _netManager = default!;
[Dependency] private readonly IPlacementManager _placementManager = default!; [Dependency] private readonly IPlacementManager _placementManager = default!;
@@ -314,37 +314,37 @@ namespace Content.Client.Sandbox
private void ToggleLight() private void ToggleLight()
{ {
_console.ProcessCommand("togglelight"); _consoleHost.ExecuteCommand("togglelight");
} }
private void ToggleFov() private void ToggleFov()
{ {
_console.ProcessCommand("togglefov"); _consoleHost.ExecuteCommand("togglefov");
} }
private void ToggleShadows() private void ToggleShadows()
{ {
_console.ProcessCommand("toggleshadows"); _consoleHost.ExecuteCommand("toggleshadows");
} }
private void ToggleSubFloor() private void ToggleSubFloor()
{ {
_console.ProcessCommand("showsubfloor"); _consoleHost.ExecuteCommand("showsubfloor");
} }
private void ShowMarkers() private void ShowMarkers()
{ {
_console.ProcessCommand("showmarkers"); _consoleHost.ExecuteCommand("showmarkers");
} }
private void ShowBb() private void ShowBb()
{ {
_console.ProcessCommand("showbb"); _consoleHost.ExecuteCommand("showbb");
} }
private void LinkMachines() private void LinkMachines()
{ {
_console.ProcessCommand("signallink"); _consoleHost.ExecuteCommand("signallink");
} }
} }
} }

View File

@@ -26,7 +26,7 @@ namespace Content.Client.State
public class LobbyState : Robust.Client.State.State public class LobbyState : Robust.Client.State.State
{ {
[Dependency] private readonly IBaseClient _baseClient = default!; [Dependency] private readonly IBaseClient _baseClient = default!;
[Dependency] private readonly IClientConsole _console = default!; [Dependency] private readonly IClientConsoleHost _consoleHost = default!;
[Dependency] private readonly IChatManager _chatManager = default!; [Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly IInputManager _inputManager = default!; [Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!; [Dependency] private readonly IEntityManager _entityManager = default!;
@@ -87,7 +87,7 @@ namespace Content.Client.State
_userInterfaceManager.StateRoot.AddChild(_characterSetup); _userInterfaceManager.StateRoot.AddChild(_characterSetup);
}; };
_lobby.ObserveButton.OnPressed += args => _console.ProcessCommand("observe"); _lobby.ObserveButton.OnPressed += args => _consoleHost.ExecuteCommand("observe");
_lobby.ReadyButton.OnPressed += args => _lobby.ReadyButton.OnPressed += args =>
{ {
if (!_clientGameTicker.IsGameStarted) if (!_clientGameTicker.IsGameStarted)
@@ -104,7 +104,7 @@ namespace Content.Client.State
SetReady(args.Pressed); SetReady(args.Pressed);
}; };
_lobby.LeaveButton.OnPressed += args => _console.ProcessCommand("disconnect"); _lobby.LeaveButton.OnPressed += args => _consoleHost.ExecuteCommand("disconnect");
_lobby.OptionsButton.OnPressed += args => new OptionsMenu().Open(); _lobby.OptionsButton.OnPressed += args => new OptionsMenu().Open();
UpdatePlayerList(); UpdatePlayerList();
@@ -259,7 +259,7 @@ namespace Content.Client.State
return; return;
} }
_console.ProcessCommand($"toggleready {newReady}"); _consoleHost.ExecuteCommand($"toggleready {newReady}");
UpdatePlayerList(); UpdatePlayerList();
} }
} }

View File

@@ -440,7 +440,7 @@ namespace Content.Client.UserInterface.AdminMenu
public override void ButtonPressed(ButtonEventArgs args) public override void ButtonPressed(ButtonEventArgs args)
{ {
IoCManager.Resolve<IClientConsole>().ProcessCommand(RequiredCommand); IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(RequiredCommand);
} }
} }
#endregion #endregion
@@ -504,7 +504,7 @@ namespace Content.Client.UserInterface.AdminMenu
Name = "Pause", Name = "Pause",
Handler = () => Handler = () =>
{ {
IoCManager.Resolve<IClientConsole>().ProcessCommand("events pause"); IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand("events pause");
}, },
}, },
new CommandUIButton new CommandUIButton
@@ -512,14 +512,14 @@ namespace Content.Client.UserInterface.AdminMenu
Name = "Resume", Name = "Resume",
Handler = () => Handler = () =>
{ {
IoCManager.Resolve<IClientConsole>().ProcessCommand("events resume"); IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand("events resume");
}, },
}, },
}; };
public override void Submit() public override void Submit()
{ {
IoCManager.Resolve<IClientConsole>().ProcessCommand($"events run \"{_eventsDropDown.GetValue()}\""); IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand($"events run \"{_eventsDropDown.GetValue()}\"");
} }
} }
@@ -548,7 +548,7 @@ namespace Content.Client.UserInterface.AdminMenu
public override void Submit() public override void Submit()
{ {
IoCManager.Resolve<IClientConsole>().ProcessCommand($"kick \"{_playerDropDown.GetValue()}\" \"{CommandParsing.Escape(_reason.GetValue())}\""); IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand($"kick \"{_playerDropDown.GetValue()}\" \"{CommandParsing.Escape(_reason.GetValue())}\"");
} }
} }
@@ -572,7 +572,7 @@ namespace Content.Client.UserInterface.AdminMenu
public override void Submit() public override void Submit()
{ {
IoCManager.Resolve<IClientConsole>().ProcessCommand($"tpto \"{_playerDropDown.GetValue()}\""); IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand($"tpto \"{_playerDropDown.GetValue()}\"");
} }
} }
@@ -596,7 +596,7 @@ namespace Content.Client.UserInterface.AdminMenu
public override void Submit() public override void Submit()
{ {
IoCManager.Resolve<IClientConsole>().ProcessCommand($"addatmos {_grid.GetValue()}"); IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand($"addatmos {_grid.GetValue()}");
} }
} }
@@ -639,7 +639,7 @@ namespace Content.Client.UserInterface.AdminMenu
public override void Submit() public override void Submit()
{ {
IoCManager.Resolve<IClientConsole>().ProcessCommand($"fillgas {_grid.GetValue()} {_gas.GetValue()} {_amount.GetValue()}"); IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand($"fillgas {_grid.GetValue()} {_gas.GetValue()} {_amount.GetValue()}");
} }
} }
#endregion #endregion

View File

@@ -22,7 +22,7 @@ namespace Content.Client.UserInterface.AdminMenu.SetOutfit
public partial class SetOutfitMenu : SS14Window public partial class SetOutfitMenu : SS14Window
{ {
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IClientConsole _console = default!; [Dependency] private readonly IClientConsoleHost _consoleHost = default!;
public EntityUid? TargetEntityId { get; set; } public EntityUid? TargetEntityId { get; set; }
protected override Vector2? CustomSize => (250, 320); protected override Vector2? CustomSize => (250, 320);
@@ -49,7 +49,7 @@ namespace Content.Client.UserInterface.AdminMenu.SetOutfit
if (TargetEntityId == null || _selectedOutfit == null) if (TargetEntityId == null || _selectedOutfit == null)
return; return;
var command = $"setoutfit {TargetEntityId} {_selectedOutfit.ID}"; var command = $"setoutfit {TargetEntityId} {_selectedOutfit.ID}";
_console.ProcessCommand(command); _consoleHost.ExecuteCommand(command);
Close(); Close();
} }

View File

@@ -8,16 +8,16 @@ namespace Content.Client.UserInterface
{ {
internal sealed class EscapeMenu : SS14Window internal sealed class EscapeMenu : SS14Window
{ {
private readonly IClientConsole _console; private readonly IClientConsoleHost _consoleHost;
private BaseButton DisconnectButton; private BaseButton DisconnectButton;
private BaseButton QuitButton; private BaseButton QuitButton;
private BaseButton OptionsButton; private BaseButton OptionsButton;
private OptionsMenu optionsMenu; private OptionsMenu optionsMenu;
public EscapeMenu(IClientConsole console) public EscapeMenu(IClientConsoleHost consoleHost)
{ {
_console = console; _consoleHost = consoleHost;
IoCManager.InjectDependencies(this); IoCManager.InjectDependencies(this);
@@ -50,13 +50,13 @@ namespace Content.Client.UserInterface
private void OnQuitButtonClicked(BaseButton.ButtonEventArgs args) private void OnQuitButtonClicked(BaseButton.ButtonEventArgs args)
{ {
_console.ProcessCommand("quit"); _consoleHost.ExecuteCommand("quit");
Dispose(); Dispose();
} }
private void OnDisconnectButtonClicked(BaseButton.ButtonEventArgs args) private void OnDisconnectButtonClicked(BaseButton.ButtonEventArgs args)
{ {
_console.ProcessCommand("disconnect"); _consoleHost.ExecuteCommand("disconnect");
Dispose(); Dispose();
} }

View File

@@ -21,7 +21,7 @@ namespace Content.Client.UserInterface
public sealed class LateJoinGui : SS14Window public sealed class LateJoinGui : SS14Window
{ {
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IClientConsole _console = default!; [Dependency] private readonly IClientConsoleHost _consoleHost = default!;
[Dependency] private readonly IClientGameTicker _gameTicker = default!; [Dependency] private readonly IClientGameTicker _gameTicker = default!;
protected override Vector2? CustomSize => (360, 560); protected override Vector2? CustomSize => (360, 560);
@@ -147,7 +147,7 @@ namespace Content.Client.UserInterface
SelectedId += jobId => SelectedId += jobId =>
{ {
Logger.InfoS("latejoin", $"Late joining as ID: {jobId}"); Logger.InfoS("latejoin", $"Late joining as ID: {jobId}");
_console.ProcessCommand($"joingame {CommandParsing.Escape(jobId)}"); _consoleHost.ExecuteCommand($"joingame {CommandParsing.Escape(jobId)}");
Close(); Close();
}; };

View File

@@ -6,7 +6,6 @@ using Content.Shared.Roles;
using Content.Shared.Preferences; using Content.Shared.Preferences;
using Content.Server.Mobs; using Content.Server.Mobs;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Server.Interfaces.Console;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Timing; using Robust.Shared.Timing;

View File

@@ -1,4 +1,5 @@
using System.Threading.Tasks; using System;
using System.Threading.Tasks;
using Content.Server.Commands.GameTicking; using Content.Server.Commands.GameTicking;
using Content.Server.GameTicking; using Content.Server.GameTicking;
using Content.Server.Interfaces.GameTicking; using Content.Server.Interfaces.GameTicking;
@@ -40,7 +41,7 @@ namespace Content.IntegrationTests.Tests.Commands
tickBeforeRestart = entityManager.CurrentTick; tickBeforeRestart = entityManager.CurrentTick;
var command = new NewRoundCommand(); var command = new NewRoundCommand();
command.Execute(null, null, new string[] { }); command.Execute(null, string.Empty, Array.Empty<string>());
if (lobbyEnabled) if (lobbyEnabled)
{ {

View File

@@ -1,4 +1,4 @@
#nullable enable #nullable enable
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Content.Client.GameObjects.Components.Items; using Content.Client.GameObjects.Components.Items;
@@ -7,7 +7,7 @@ using Content.Server.GameObjects.Components.Body;
using Content.Server.Interfaces.GameObjects.Components.Items; using Content.Server.Interfaces.GameObjects.Components.Items;
using Content.Shared.GameObjects.Components.Body; using Content.Shared.GameObjects.Components.Body;
using NUnit.Framework; using NUnit.Framework;
using Robust.Server.Interfaces.Console; using Robust.Server.Console;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -96,8 +96,8 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking
private void AddHand(IEntity to) private void AddHand(IEntity to)
{ {
var shell = IoCManager.Resolve<IConsoleShell>(); var host = IoCManager.Resolve<IServerConsoleHost>();
shell.ExecuteCommand($"addhand {to.Uid}"); host.ExecuteCommand(null, $"addhand {to.Uid}");
} }
} }
} }

View File

@@ -27,7 +27,7 @@ namespace Content.IntegrationTests.Tests.Networking
await Task.WhenAll(client.WaitIdleAsync(), server.WaitIdleAsync()); await Task.WhenAll(client.WaitIdleAsync(), server.WaitIdleAsync());
await client.WaitPost(() => IoCManager.Resolve<IClientConsole>().ProcessCommand("disconnect")); await client.WaitPost(() => IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand("disconnect"));
// Run some ticks for the disconnect to complete and such. // Run some ticks for the disconnect to complete and such.
await RunTicksSync(client, server, 5); await RunTicksSync(client, server, 5);

View File

@@ -1,7 +1,7 @@
using System; using System;
using Content.Shared.Administration; using Content.Shared.Administration;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.Interfaces.Console; using Robust.Shared.Console;
namespace Content.Server.Administration namespace Content.Server.Administration
{ {
@@ -13,7 +13,7 @@ namespace Content.Server.Administration
/// </remarks> /// </remarks>
/// <seealso cref="AnyCommandAttribute"/> /// <seealso cref="AnyCommandAttribute"/>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
[BaseTypeRequired(typeof(IClientCommand))] [BaseTypeRequired(typeof(IConsoleCommand))]
[MeansImplicitUse] [MeansImplicitUse]
public sealed class AdminCommandAttribute : Attribute public sealed class AdminCommandAttribute : Attribute
{ {

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@@ -12,9 +12,9 @@ using Content.Shared;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Network.NetMessages; using Content.Shared.Network.NetMessages;
using Robust.Server.Console; using Robust.Server.Console;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums; using Robust.Shared.Enums;
using Robust.Shared.Interfaces.Configuration; using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.Interfaces.Network; using Robust.Shared.Interfaces.Network;
@@ -37,7 +37,7 @@ namespace Content.Server.Administration
[Dependency] private readonly IServerNetManager _netMgr = default!; [Dependency] private readonly IServerNetManager _netMgr = default!;
[Dependency] private readonly IConGroupController _conGroup = default!; [Dependency] private readonly IConGroupController _conGroup = default!;
[Dependency] private readonly IResourceManager _res = default!; [Dependency] private readonly IResourceManager _res = default!;
[Dependency] private readonly IConsoleShell _consoleShell = default!; [Dependency] private readonly IServerConsoleHost _consoleHost = default!;
[Dependency] private readonly IChatManager _chat = default!; [Dependency] private readonly IChatManager _chat = default!;
private readonly Dictionary<IPlayerSession, AdminReg> _admins = new(); private readonly Dictionary<IPlayerSession, AdminReg> _admins = new();
@@ -171,7 +171,7 @@ namespace Content.Server.Administration
_netMgr.RegisterNetMessage<MsgUpdateAdminStatus>(MsgUpdateAdminStatus.NAME); _netMgr.RegisterNetMessage<MsgUpdateAdminStatus>(MsgUpdateAdminStatus.NAME);
// Cache permissions for loaded console commands with the requisite attributes. // Cache permissions for loaded console commands with the requisite attributes.
foreach (var (cmdName, cmd) in _consoleShell.AvailableCommands) foreach (var (cmdName, cmd) in _consoleHost.RegisteredCommands)
{ {
var (isAvail, flagsReq) = GetRequiredFlag(cmd); var (isAvail, flagsReq) = GetRequiredFlag(cmd);
@@ -420,7 +420,7 @@ namespace Content.Server.Administration
return false; return false;
} }
private static (bool isAvail, AdminFlags[] flagsReq) GetRequiredFlag(IClientCommand cmd) private static (bool isAvail, AdminFlags[] flagsReq) GetRequiredFlag(IConsoleCommand cmd)
{ {
var type = cmd.GetType(); var type = cmd.GetType();
if (Attribute.IsDefined(type, typeof(AnyCommandAttribute))) if (Attribute.IsDefined(type, typeof(AnyCommandAttribute)))

View File

@@ -1,6 +1,6 @@
using System; using System;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.Interfaces.Console; using Robust.Shared.Console;
namespace Content.Server.Administration namespace Content.Server.Administration
{ {
@@ -9,7 +9,7 @@ namespace Content.Server.Administration
/// </summary> /// </summary>
/// <seealso cref="AdminCommandAttribute"/> /// <seealso cref="AdminCommandAttribute"/>
[AttributeUsage(AttributeTargets.Class)] [AttributeUsage(AttributeTargets.Class)]
[BaseTypeRequired(typeof(IClientCommand))] [BaseTypeRequired(typeof(IConsoleCommand))]
[MeansImplicitUse] [MeansImplicitUse]
public sealed class AnyCommandAttribute : Attribute public sealed class AnyCommandAttribute : Attribute
{ {

View File

@@ -3,25 +3,26 @@ using Content.Server.GameObjects.Components.Observer;
using Content.Server.Interfaces.GameTicking; using Content.Server.Interfaces.GameTicking;
using Content.Server.Players; using Content.Server.Players;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Administration.Commands namespace Content.Server.Administration.Commands
{ {
[AdminCommand(AdminFlags.Admin)] [AdminCommand(AdminFlags.Admin)]
public class AGhost : IClientCommand public class AGhost : IConsoleCommand
{ {
public string Command => "aghost"; public string Command => "aghost";
public string Description => "Makes you an admin ghost."; public string Description => "Makes you an admin ghost.";
public string Help => "aghost"; public string Help => "aghost";
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) if (player == null)
{ {
shell.SendText((IPlayerSession) null, "Nah"); shell.WriteLine("Nah");
return; return;
} }
@@ -29,7 +30,7 @@ namespace Content.Server.Administration.Commands
if (mind == null) if (mind == null)
{ {
shell.SendText(player, "You can't ghost here!"); shell.WriteLine("You can't ghost here!");
return; return;
} }

View File

@@ -1,8 +1,8 @@
using System; using System;
using Content.Server.Database; using Content.Server.Database;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Network; using Robust.Shared.Network;
@@ -11,14 +11,15 @@ using Robust.Shared.Network;
namespace Content.Server.Administration.Commands namespace Content.Server.Administration.Commands
{ {
[AdminCommand(AdminFlags.Ban)] [AdminCommand(AdminFlags.Ban)]
public sealed class BanCommand : IClientCommand public sealed class BanCommand : IConsoleCommand
{ {
public string Command => "ban"; public string Command => "ban";
public string Description => "Bans somebody"; public string Description => "Bans somebody";
public string Help => "Usage: <name or user ID> <reason> <duration in minutes, or 0 for permanent ban>"; public string Help => "Usage: <name or user ID> <reason> <duration in minutes, or 0 for permanent ban>";
public async void Execute(IConsoleShell shell, IPlayerSession? player, string[] args) public async void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var player = shell.Player as IPlayerSession;
var plyMgr = IoCManager.Resolve<IPlayerManager>(); var plyMgr = IoCManager.Resolve<IPlayerManager>();
var dbMan = IoCManager.Resolve<IServerDbManager>(); var dbMan = IoCManager.Resolve<IServerDbManager>();
@@ -37,7 +38,7 @@ namespace Content.Server.Administration.Commands
} }
else else
{ {
shell.SendText(player, "Unable to find user with that name."); shell.WriteLine("Unable to find user with that name.");
return; return;
} }

View File

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

View File

@@ -1,14 +1,14 @@
using Content.Server.Interfaces.Chat; using Content.Server.Interfaces.Chat;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
namespace Content.Server.Administration.Commands namespace Content.Server.Administration.Commands
{ {
[AdminCommand(AdminFlags.Admin)] [AdminCommand(AdminFlags.Admin)]
class DSay : IClientCommand class DSay : IConsoleCommand
{ {
public string Command => "dsay"; public string Command => "dsay";
@@ -16,11 +16,12 @@ namespace Content.Server.Administration.Commands
public string Help => Loc.GetString($"Usage: {Command} <message>"); public string Help => Loc.GetString($"Usage: {Command} <message>");
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) if (player == null)
{ {
shell.SendText((IPlayerSession) null, "Only players can use this command"); shell.WriteLine("Only players can use this command");
return; return;
} }

View File

@@ -1,7 +1,7 @@
using Content.Shared.Administration; using Content.Shared.Administration;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
#nullable enable #nullable enable
@@ -10,17 +10,18 @@ namespace Content.Server.Administration.Commands
{ {
[UsedImplicitly] [UsedImplicitly]
[AdminCommand(AdminFlags.None)] [AdminCommand(AdminFlags.None)]
public class DeAdminCommand : IClientCommand public class DeAdminCommand : IConsoleCommand
{ {
public string Command => "deadmin"; public string Command => "deadmin";
public string Description => "Temporarily de-admins you so you can experience the round as a normal player."; public string Description => "Temporarily de-admins you so you can experience the round as a normal player.";
public string Help => "Usage: deadmin\nUse readmin to re-admin after using this."; public string Help => "Usage: deadmin\nUse readmin to re-admin after using this.";
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) if (player == null)
{ {
shell.SendText(player, "You cannot use this command from the server console."); shell.WriteLine("You cannot use this command from the server console.");
return; return;
} }

View File

@@ -1,25 +1,25 @@
#nullable enable #nullable enable
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Administration.Commands namespace Content.Server.Administration.Commands
{ {
[AdminCommand(AdminFlags.Admin)] [AdminCommand(AdminFlags.Admin)]
public class DeleteComponent : IClientCommand public class DeleteComponent : IConsoleCommand
{ {
public string Command => "deletecomponent"; public string Command => "deletecomponent";
public string Description => "Deletes all instances of the specified component."; public string Description => "Deletes all instances of the specified component.";
public string Help => $"Usage: {Command} <name>"; public string Help => $"Usage: {Command} <name>";
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
switch (args.Length) switch (args.Length)
{ {
case 0: case 0:
shell.SendText(player, $"Not enough arguments.\n{Help}"); shell.WriteLine($"Not enough arguments.\n{Help}");
break; break;
default: default:
var name = string.Join(" ", args); var name = string.Join(" ", args);
@@ -28,7 +28,7 @@ namespace Content.Server.Administration.Commands
if (!componentFactory.TryGetRegistration(name, out var registration)) if (!componentFactory.TryGetRegistration(name, out var registration))
{ {
shell.SendText(player, $"No component exists with name {name}."); shell.WriteLine($"No component exists with name {name}.");
break; break;
} }
@@ -44,7 +44,7 @@ namespace Content.Server.Administration.Commands
i++; i++;
} }
shell.SendText(player, $"Removed {i} components with name {name}."); shell.WriteLine($"Removed {i} components with name {name}.");
break; break;
} }

View File

@@ -1,8 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -11,7 +11,7 @@ using Robust.Shared.Localization;
namespace Content.Server.Administration.Commands namespace Content.Server.Administration.Commands
{ {
[AdminCommand(AdminFlags.Admin)] [AdminCommand(AdminFlags.Admin)]
class DeleteEntitiesWithComponent : IClientCommand class DeleteEntitiesWithComponent : IConsoleCommand
{ {
public string Command => "deleteewc"; public string Command => "deleteewc";
public string Description public string Description
@@ -29,11 +29,11 @@ namespace Content.Server.Administration.Commands
} }
} }
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length < 1) if (args.Length < 1)
{ {
shell.SendText(player, Help); shell.WriteLine(Help);
return; return;
} }
@@ -54,7 +54,7 @@ namespace Content.Server.Administration.Commands
count += 1; count += 1;
} }
shell.SendText(player, Loc.GetString("Deleted {0} entities", count)); shell.WriteLine(Loc.GetString("Deleted {0} entities", count));
} }
} }
} }

View File

@@ -1,7 +1,7 @@
#nullable enable #nullable enable
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -9,17 +9,17 @@ using Robust.Shared.IoC;
namespace Content.Server.Administration.Commands namespace Content.Server.Administration.Commands
{ {
[AdminCommand(AdminFlags.Admin)] [AdminCommand(AdminFlags.Admin)]
public class DeleteEntitiesWithId : IClientCommand public class DeleteEntitiesWithId : IConsoleCommand
{ {
public string Command => "deleteewi"; public string Command => "deleteewi";
public string Description => "Deletes entities with the specified prototype ID."; public string Description => "Deletes entities with the specified prototype ID.";
public string Help => $"Usage: {Command} <prototypeID>"; public string Help => $"Usage: {Command} <prototypeID>";
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length != 1) if (args.Length != 1)
{ {
shell.SendText(player, Help); shell.WriteLine(Help);
return; return;
} }
@@ -35,7 +35,7 @@ namespace Content.Server.Administration.Commands
i++; i++;
} }
shell.SendText(player, $"Deleted all entities with id {id}. Occurrences: {i}"); shell.WriteLine($"Deleted all entities with id {id}. Occurrences: {i}");
} }
} }
} }

View File

@@ -1,7 +1,7 @@
using Content.Server.Explosions; using Content.Server.Explosions;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.Map; using Robust.Shared.Map;
#nullable enable #nullable enable
@@ -9,18 +9,19 @@ using Robust.Shared.Map;
namespace Content.Server.Administration.Commands namespace Content.Server.Administration.Commands
{ {
[AdminCommand(AdminFlags.Fun)] [AdminCommand(AdminFlags.Fun)]
public sealed class ExplosionCommand : IClientCommand public sealed class ExplosionCommand : IConsoleCommand
{ {
public string Command => "explode"; public string Command => "explode";
public string Description => "Train go boom"; public string Description => "Train go boom";
public string Help => "Usage: explode <x> <y> <dev> <heavy> <light> <flash>\n" + public string Help => "Usage: explode <x> <y> <dev> <heavy> <light> <flash>\n" +
"The explosion happens on the same map as the user."; "The explosion happens on the same map as the user.";
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) if (player?.AttachedEntity == null)
{ {
shell.SendText(player, "You must have an attached entity."); shell.WriteLine("You must have an attached entity.");
return; return;
} }

View File

@@ -1,7 +1,7 @@
using Content.Server.Eui; using Content.Server.Eui;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
#nullable enable #nullable enable
@@ -9,17 +9,18 @@ using Robust.Shared.IoC;
namespace Content.Server.Administration.Commands namespace Content.Server.Administration.Commands
{ {
[AdminCommand(AdminFlags.Permissions)] [AdminCommand(AdminFlags.Permissions)]
public sealed class OpenPermissionsCommand : IClientCommand public sealed class OpenPermissionsCommand : IConsoleCommand
{ {
public string Command => "permissions"; public string Command => "permissions";
public string Description => "Opens the admin permissions panel."; public string Description => "Opens the admin permissions panel.";
public string Help => "Usage: permissions"; public string Help => "Usage: permissions";
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) if (player == null)
{ {
shell.SendText(player, "This does not work from the server console."); shell.WriteLine("This does not work from the server console.");
return; return;
} }

View File

@@ -1,30 +1,30 @@
#nullable enable #nullable enable
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Administration.Commands namespace Content.Server.Administration.Commands
{ {
[UsedImplicitly] [UsedImplicitly]
public sealed class PromoteHostCommand : IClientCommand public sealed class PromoteHostCommand : IConsoleCommand
{ {
public string Command => "promotehost"; public string Command => "promotehost";
public string Description => "Grants client temporary full host admin privileges. Use this to bootstrap admins."; public string Description => "Grants client temporary full host admin privileges. Use this to bootstrap admins.";
public string Help => "Usage promotehost <player>"; public string Help => "Usage promotehost <player>";
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length != 1) if (args.Length != 1)
{ {
shell.SendText(player, "Expected exactly one argument."); shell.WriteLine("Expected exactly one argument.");
return; return;
} }
var plyMgr = IoCManager.Resolve<IPlayerManager>(); var plyMgr = IoCManager.Resolve<IPlayerManager>();
if (!plyMgr.TryGetSessionByUsername(args[0], out var targetPlayer)) if (!plyMgr.TryGetSessionByUsername(args[0], out var targetPlayer))
{ {
shell.SendText(player, "Unable to find a player by that name."); shell.WriteLine("Unable to find a player by that name.");
return; return;
} }

View File

@@ -1,5 +1,5 @@
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
#nullable enable #nullable enable
@@ -7,17 +7,18 @@ using Robust.Shared.IoC;
namespace Content.Server.Administration.Commands namespace Content.Server.Administration.Commands
{ {
[AnyCommand] [AnyCommand]
public class ReAdminCommand : IClientCommand public class ReAdminCommand : IConsoleCommand
{ {
public string Command => "readmin"; public string Command => "readmin";
public string Description => "Re-admins you if you previously de-adminned."; public string Description => "Re-admins you if you previously de-adminned.";
public string Help => "Usage: readmin"; public string Help => "Usage: readmin";
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) if (player == null)
{ {
shell.SendText(player, "You cannot use this command from the server console."); shell.WriteLine("You cannot use this command from the server console.");
return; return;
} }
@@ -25,7 +26,7 @@ namespace Content.Server.Administration.Commands
if (mgr.GetAdminData(player, includeDeAdmin: true) == null) if (mgr.GetAdminData(player, includeDeAdmin: true) == null)
{ {
shell.SendText(player, "You're not an admin."); shell.WriteLine("You're not an admin.");
return; return;
} }

View File

@@ -2,19 +2,19 @@
using Content.Server.GameTicking; using Content.Server.GameTicking;
using Content.Server.Interfaces.GameTicking; using Content.Server.Interfaces.GameTicking;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Administration.Commands namespace Content.Server.Administration.Commands
{ {
[AdminCommand(AdminFlags.Server)] [AdminCommand(AdminFlags.Server)]
public class ReadyAll : IClientCommand public class ReadyAll : IConsoleCommand
{ {
public string Command => "readyall"; public string Command => "readyall";
public string Description => "Readies up all players in the lobby."; public string Description => "Readies up all players in the lobby.";
public string Help => $"{Command} | ̣{Command} <ready>"; public string Help => $"{Command} | ̣{Command} <ready>";
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var ready = true; var ready = true;
@@ -29,7 +29,7 @@ namespace Content.Server.Administration.Commands
if (gameTicker.RunLevel != GameRunLevel.PreRoundLobby) if (gameTicker.RunLevel != GameRunLevel.PreRoundLobby)
{ {
shell.SendText(player, "This command can only be ran while in the lobby!"); shell.WriteLine("This command can only be ran while in the lobby!");
return; return;
} }

View File

@@ -1,7 +1,7 @@
using Content.Server.GlobalVerbs; using Content.Server.GlobalVerbs;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -10,7 +10,7 @@ using Robust.Shared.Localization;
namespace Content.Server.Administration.Commands namespace Content.Server.Administration.Commands
{ {
[AdminCommand(AdminFlags.Admin)] [AdminCommand(AdminFlags.Admin)]
class Rejuvenate : IClientCommand class Rejuvenate : IConsoleCommand
{ {
public string Command => "rejuvenate"; public string Command => "rejuvenate";
public string Description public string Description
@@ -28,14 +28,15 @@ namespace Content.Server.Administration.Commands
} }
} }
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 (args.Length < 1 && player != null) //Try to heal the users mob if applicable if (args.Length < 1 && player != null) //Try to heal the users mob if applicable
{ {
shell.SendText(player, Loc.GetString("Healing the user's mob since no arguments were provided.")); shell.WriteLine(Loc.GetString("Healing the user's mob since no arguments were provided."));
if (player.AttachedEntity == null) if (player.AttachedEntity == null)
{ {
shell.SendText(player, Loc.GetString("There's no entity attached to the user.")); shell.WriteLine(Loc.GetString("There's no entity attached to the user."));
return; return;
} }
RejuvenateVerb.PerformRejuvenate(player.AttachedEntity); RejuvenateVerb.PerformRejuvenate(player.AttachedEntity);
@@ -46,7 +47,7 @@ namespace Content.Server.Administration.Commands
{ {
if(!EntityUid.TryParse(arg, out var uid) || !entityManager.TryGetEntity(uid, out var entity)) if(!EntityUid.TryParse(arg, out var uid) || !entityManager.TryGetEntity(uid, out var entity))
{ {
shell.SendText(player, Loc.GetString("Could not find entity {0}", arg)); shell.WriteLine(Loc.GetString("Could not find entity {0}", arg));
continue; continue;
} }
RejuvenateVerb.PerformRejuvenate(entity); RejuvenateVerb.PerformRejuvenate(entity);

View File

@@ -3,8 +3,8 @@ using Content.Server.GameObjects.Components.GUI;
using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.GameObjects.Components.Items.Storage;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Roles; using Content.Shared.Roles;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -14,7 +14,7 @@ using Robust.Shared.Prototypes;
namespace Content.Server.Administration.Commands namespace Content.Server.Administration.Commands
{ {
[AdminCommand(AdminFlags.Admin)] [AdminCommand(AdminFlags.Admin)]
class SetOutfitCommand : IClientCommand class SetOutfitCommand : IConsoleCommand
{ {
public string Command => "setoutfit"; public string Command => "setoutfit";
@@ -22,17 +22,17 @@ namespace Content.Server.Administration.Commands
public string Help => Loc.GetString("Usage: {0} <entityUid> | {0} <entityUid> <outfitId>", Command); public string Help => Loc.GetString("Usage: {0} <entityUid> | {0} <entityUid> <outfitId>", Command);
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length < 1) if (args.Length < 1)
{ {
shell.SendText(player, Loc.GetString("Wrong number of arguments.")); shell.WriteLine(Loc.GetString("Wrong number of arguments."));
return; return;
} }
if (!int.TryParse(args[0], out var entityUid)) if (!int.TryParse(args[0], out var entityUid))
{ {
shell.SendText(player, Loc.GetString("EntityUid must be a number.")); shell.WriteLine(Loc.GetString("EntityUid must be a number."));
return; return;
} }
@@ -42,7 +42,7 @@ namespace Content.Server.Administration.Commands
if (!eUid.IsValid() || !entityManager.EntityExists(eUid)) if (!eUid.IsValid() || !entityManager.EntityExists(eUid))
{ {
shell.SendText(player, Loc.GetString("Invalid entity ID.")); shell.WriteLine(Loc.GetString("Invalid entity ID."));
return; return;
} }
@@ -50,7 +50,7 @@ namespace Content.Server.Administration.Commands
if (!target.TryGetComponent<InventoryComponent>(out var inventoryComponent)) if (!target.TryGetComponent<InventoryComponent>(out var inventoryComponent))
{ {
shell.SendText(player, Loc.GetString("Target entity does not have an inventory!")); shell.WriteLine(Loc.GetString("Target entity does not have an inventory!"));
return; return;
} }
@@ -58,6 +58,7 @@ namespace Content.Server.Administration.Commands
{ {
var eui = IoCManager.Resolve<EuiManager>(); var eui = IoCManager.Resolve<EuiManager>();
var ui = new SetOutfitEui(target); var ui = new SetOutfitEui(target);
var player = shell.Player as IPlayerSession;
eui.OpenEui(ui, player); eui.OpenEui(ui, player);
return; return;
} }
@@ -65,7 +66,7 @@ namespace Content.Server.Administration.Commands
var prototypeManager = IoCManager.Resolve<IPrototypeManager>(); var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
if (!prototypeManager.TryIndex<StartingGearPrototype>(args[1], out var startingGear)) if (!prototypeManager.TryIndex<StartingGearPrototype>(args[1], out var startingGear))
{ {
shell.SendText(player, Loc.GetString("Invalid outfit id")); shell.WriteLine(Loc.GetString("Invalid outfit id"));
return; return;
} }

View File

@@ -1,9 +1,9 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Content.Server.GameObjects.Components.Markers; using Content.Server.GameObjects.Components.Markers;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums; using Robust.Shared.Enums;
using Robust.Shared.GameObjects.Components; using Robust.Shared.GameObjects.Components;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
@@ -14,7 +14,7 @@ using Robust.Shared.Map;
namespace Content.Server.Administration.Commands namespace Content.Server.Administration.Commands
{ {
[AdminCommand(AdminFlags.Admin)] [AdminCommand(AdminFlags.Admin)]
public class WarpCommand : IClientCommand public class WarpCommand : IConsoleCommand
{ {
public string Command => "warp"; public string Command => "warp";
public string Description => "Teleports you to predefined areas on the map."; public string Description => "Teleports you to predefined areas on the map.";
@@ -23,17 +23,18 @@ namespace Content.Server.Administration.Commands
"warp <location>\nLocations you can teleport to are predefined by the map. " + "warp <location>\nLocations you can teleport to are predefined by the map. " +
"You can specify '?' as location to get a list of valid locations."; "You can specify '?' as location to get a list of valid locations.";
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) if (player == null)
{ {
shell.SendText((IPlayerSession) null, "Only players can use this command"); shell.WriteLine("Only players can use this command");
return; return;
} }
if (args.Length != 1) if (args.Length != 1)
{ {
shell.SendText(player, "Expected a single argument."); shell.WriteLine("Expected a single argument.");
return; return;
} }
@@ -48,13 +49,13 @@ namespace Content.Server.Administration.Commands
.OrderBy(p => p) .OrderBy(p => p)
.Distinct()); .Distinct());
shell.SendText(player, locations); shell.WriteLine(locations);
} }
else else
{ {
if (player.Status != SessionStatus.InGame || player.AttachedEntity == null) if (player.Status != SessionStatus.InGame || player.AttachedEntity == null)
{ {
shell.SendText(player, "You are not in-game!"); shell.WriteLine("You are not in-game!");
return; return;
} }
@@ -121,7 +122,7 @@ namespace Content.Server.Administration.Commands
} }
else else
{ {
shell.SendText(player, "That location does not exist!"); shell.WriteLine("That location does not exist!");
} }
} }
} }

View File

@@ -4,8 +4,8 @@ using Content.Server.GameObjects.Components.Movement;
using Content.Server.GameObjects.EntitySystems.AI; using Content.Server.GameObjects.EntitySystems.AI;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.GameObjects.Components.Movement; using Content.Shared.GameObjects.Components.Movement;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
@@ -14,7 +14,7 @@ using Robust.Shared.IoC;
namespace Content.Server.Commands.AI namespace Content.Server.Commands.AI
{ {
[AdminCommand(AdminFlags.Fun)] [AdminCommand(AdminFlags.Fun)]
public class AddAiCommand : IClientCommand public class AddAiCommand : IConsoleCommand
{ {
public string Command => "addai"; public string Command => "addai";
public string Description => "Add an ai component with a given processor to an entity."; public string Description => "Add an ai component with a given processor to an entity.";
@@ -22,11 +22,11 @@ namespace Content.Server.Commands.AI
+ "\n processorId: Class that inherits AiLogicProcessor and has an AiLogicProcessor attribute." + "\n processorId: Class that inherits AiLogicProcessor and has an AiLogicProcessor attribute."
+ "\n entityID: Uid of entity to add the AiControllerComponent to. Open its VV menu to find this."; + "\n entityID: Uid of entity to add the AiControllerComponent to. Open its VV menu to find this.";
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if(args.Length != 2) if(args.Length != 2)
{ {
shell.SendText(player, "Wrong number of args."); shell.WriteLine("Wrong number of args.");
return; return;
} }
@@ -37,12 +37,12 @@ namespace Content.Server.Commands.AI
if (!aiSystem.ProcessorTypeExists(processorId)) if (!aiSystem.ProcessorTypeExists(processorId))
{ {
shell.SendText(player, "Invalid processor type. Processor must inherit AiLogicProcessor and have an AiLogicProcessor attribute."); shell.WriteLine("Invalid processor type. Processor must inherit AiLogicProcessor and have an AiLogicProcessor attribute.");
return; return;
} }
if (ent.HasComponent<AiControllerComponent>()) if (ent.HasComponent<AiControllerComponent>())
{ {
shell.SendText(player, "Entity already has an AI component."); shell.WriteLine("Entity already has an AI component.");
return; return;
} }
@@ -53,7 +53,7 @@ namespace Content.Server.Commands.AI
var comp = ent.AddComponent<AiControllerComponent>(); var comp = ent.AddComponent<AiControllerComponent>();
comp.LogicName = processorId; comp.LogicName = processorId;
shell.SendText(player, "AI component added."); shell.WriteLine("AI component added.");
} }
} }
} }

View File

@@ -4,22 +4,22 @@ using Content.Server.Administration;
using Content.Server.GameObjects.Components.AI; using Content.Server.GameObjects.Components.AI;
using Content.Server.GameObjects.EntitySystems.AI; using Content.Server.GameObjects.EntitySystems.AI;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Localization; using Robust.Shared.Localization;
namespace Content.Server.Commands.AI namespace Content.Server.Commands.AI
{ {
[AdminCommand(AdminFlags.Fun)] [AdminCommand(AdminFlags.Fun)]
public sealed class FactionCommand : IClientCommand public sealed class FactionCommand : IConsoleCommand
{ {
public string Command => "factions"; public string Command => "factions";
public string Description => "Update / list factional relationships for NPCs."; public string Description => "Update / list factional relationships for NPCs.";
public string Help => "faction <source> <friendly/hostile> target\n" + public string Help => "faction <source> <friendly/hostile> target\n" +
"faction <source> list: hostile factions"; "faction <source> list: hostile factions";
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length == 0) if (args.Length == 0)
{ {
@@ -31,19 +31,19 @@ namespace Content.Server.Commands.AI
result.Append(value + "\n"); result.Append(value + "\n");
} }
shell.SendText(player, result.ToString()); shell.WriteLine(result.ToString());
return; return;
} }
if (args.Length < 2) if (args.Length < 2)
{ {
shell.SendText(player, Loc.GetString("Need more args")); shell.WriteLine(Loc.GetString("Need more args"));
return; return;
} }
if (!Enum.TryParse(args[0], true, out Faction faction)) if (!Enum.TryParse(args[0], true, out Faction faction))
{ {
shell.SendText(player, Loc.GetString("Invalid faction")); shell.WriteLine(Loc.GetString("Invalid faction"));
return; return;
} }
@@ -54,40 +54,40 @@ namespace Content.Server.Commands.AI
case "friendly": case "friendly":
if (args.Length < 3) if (args.Length < 3)
{ {
shell.SendText(player, Loc.GetString("Need to supply a target faction")); shell.WriteLine(Loc.GetString("Need to supply a target faction"));
return; return;
} }
if (!Enum.TryParse(args[2], true, out targetFaction)) if (!Enum.TryParse(args[2], true, out targetFaction))
{ {
shell.SendText(player, Loc.GetString("Invalid target faction")); shell.WriteLine(Loc.GetString("Invalid target faction"));
return; return;
} }
EntitySystem.Get<AiFactionTagSystem>().MakeFriendly(faction, targetFaction); EntitySystem.Get<AiFactionTagSystem>().MakeFriendly(faction, targetFaction);
shell.SendText(player, Loc.GetString("Command successful")); shell.WriteLine(Loc.GetString("Command successful"));
break; break;
case "hostile": case "hostile":
if (args.Length < 3) if (args.Length < 3)
{ {
shell.SendText(player, Loc.GetString("Need to supply a target faction")); shell.WriteLine(Loc.GetString("Need to supply a target faction"));
return; return;
} }
if (!Enum.TryParse(args[2], true, out targetFaction)) if (!Enum.TryParse(args[2], true, out targetFaction))
{ {
shell.SendText(player, Loc.GetString("Invalid target faction")); shell.WriteLine(Loc.GetString("Invalid target faction"));
return; return;
} }
EntitySystem.Get<AiFactionTagSystem>().MakeHostile(faction, targetFaction); EntitySystem.Get<AiFactionTagSystem>().MakeHostile(faction, targetFaction);
shell.SendText(player, Loc.GetString("Command successful")); shell.WriteLine(Loc.GetString("Command successful"));
break; break;
case "list": case "list":
shell.SendText(player, EntitySystem.Get<AiFactionTagSystem>().GetHostileFactions(faction).ToString()); shell.WriteLine(EntitySystem.Get<AiFactionTagSystem>().GetHostileFactions(faction).ToString());
break; break;
default: default:
shell.SendText(player, Loc.GetString("Unknown faction arg")); shell.WriteLine(Loc.GetString("Unknown faction arg"));
break; break;
} }

View File

@@ -1,25 +1,26 @@
#nullable enable #nullable enable
using System; using System;
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.GameObjects.Components.Mobs; using Content.Server.GameObjects.Components.Mobs;
using Content.Shared.Actions; using Content.Shared.Actions;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.Interfaces.Timing; using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Commands.Actions namespace Content.Server.Commands.Actions
{ {
[AdminCommand(AdminFlags.Debug)] [AdminCommand(AdminFlags.Debug)]
public sealed class CooldownAction : IClientCommand public sealed class CooldownAction : IConsoleCommand
{ {
public string Command => "coolaction"; public string Command => "coolaction";
public string Description => "Sets a cooldown on an action for a player, defaulting to current player"; public string Description => "Sets a cooldown on an action for a player, defaulting to current player";
public string Help => "coolaction <actionType> <seconds> <name or userID, omit for current player>"; public string Help => "coolaction <actionType> <seconds> <name or userID, omit for current player>";
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) return; if (player == null) return;
var attachedEntity = player.AttachedEntity; var attachedEntity = player.AttachedEntity;
if (args.Length > 2) if (args.Length > 2)
@@ -31,29 +32,29 @@ namespace Content.Server.Commands.Actions
if (attachedEntity == null) return; if (attachedEntity == null) return;
if (!attachedEntity.TryGetComponent(out ServerActionsComponent? actionsComponent)) if (!attachedEntity.TryGetComponent(out ServerActionsComponent? actionsComponent))
{ {
shell.SendText(player, "user has no actions component"); shell.WriteLine("user has no actions component");
return; return;
} }
var actionTypeRaw = args[0]; var actionTypeRaw = args[0];
if (!Enum.TryParse<ActionType>(actionTypeRaw, out var actionType)) if (!Enum.TryParse<ActionType>(actionTypeRaw, out var actionType))
{ {
shell.SendText(player, "unrecognized ActionType enum value, please" + shell.WriteLine("unrecognized ActionType enum value, please" +
" ensure you used correct casing: " + actionTypeRaw); " ensure you used correct casing: " + actionTypeRaw);
return; return;
} }
var actionMgr = IoCManager.Resolve<ActionManager>(); var actionMgr = IoCManager.Resolve<ActionManager>();
if (!actionMgr.TryGet(actionType, out var action)) if (!actionMgr.TryGet(actionType, out var action))
{ {
shell.SendText(player, "unrecognized actionType " + actionType); shell.WriteLine("unrecognized actionType " + actionType);
return; return;
} }
var cooldownStart = IoCManager.Resolve<IGameTiming>().CurTime; var cooldownStart = IoCManager.Resolve<IGameTiming>().CurTime;
if (!uint.TryParse(args[1], out var seconds)) if (!uint.TryParse(args[1], out var seconds))
{ {
shell.SendText(player, "cannot parse seconds: " + args[1]); shell.WriteLine("cannot parse seconds: " + args[1]);
return; return;
} }

View File

@@ -1,23 +1,24 @@
#nullable enable #nullable enable
using System; using System;
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.GameObjects.Components.Mobs; using Content.Server.GameObjects.Components.Mobs;
using Content.Shared.Actions; using Content.Shared.Actions;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Commands.Actions namespace Content.Server.Commands.Actions
{ {
[AdminCommand(AdminFlags.Debug)] [AdminCommand(AdminFlags.Debug)]
public sealed class GrantAction : IClientCommand public sealed class GrantAction : IConsoleCommand
{ {
public string Command => "grantaction"; public string Command => "grantaction";
public string Description => "Grants an action to a player, defaulting to current player"; public string Description => "Grants an action to a player, defaulting to current player";
public string Help => "grantaction <actionType> <name or userID, omit for current player>"; public string Help => "grantaction <actionType> <name or userID, omit for current player>";
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) return; if (player == null) return;
var attachedEntity = player.AttachedEntity; var attachedEntity = player.AttachedEntity;
if (args.Length > 1) if (args.Length > 1)
@@ -29,21 +30,21 @@ namespace Content.Server.Commands.Actions
if (attachedEntity == null) return; if (attachedEntity == null) return;
if (!attachedEntity.TryGetComponent(out ServerActionsComponent? actionsComponent)) if (!attachedEntity.TryGetComponent(out ServerActionsComponent? actionsComponent))
{ {
shell.SendText(player, "user has no actions component"); shell.WriteLine("user has no actions component");
return; return;
} }
var actionTypeRaw = args[0]; var actionTypeRaw = args[0];
if (!Enum.TryParse<ActionType>(actionTypeRaw, out var actionType)) if (!Enum.TryParse<ActionType>(actionTypeRaw, out var actionType))
{ {
shell.SendText(player, "unrecognized ActionType enum value, please" + shell.WriteLine("unrecognized ActionType enum value, please" +
" ensure you used correct casing: " + actionTypeRaw); " ensure you used correct casing: " + actionTypeRaw);
return; return;
} }
var actionMgr = IoCManager.Resolve<ActionManager>(); var actionMgr = IoCManager.Resolve<ActionManager>();
if (!actionMgr.TryGet(actionType, out var action)) if (!actionMgr.TryGet(actionType, out var action))
{ {
shell.SendText(player, "unrecognized actionType " + actionType); shell.WriteLine("unrecognized actionType " + actionType);
return; return;
} }
actionsComponent.Grant(action.ActionType); actionsComponent.Grant(action.ActionType);

View File

@@ -1,24 +1,25 @@
#nullable enable #nullable enable
using System; using System;
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.GameObjects.Components.Mobs; using Content.Server.GameObjects.Components.Mobs;
using Content.Shared.Actions; using Content.Shared.Actions;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Commands.Actions namespace Content.Server.Commands.Actions
{ {
[AdminCommand(AdminFlags.Debug)] [AdminCommand(AdminFlags.Debug)]
public sealed class RevokeAction : IClientCommand public sealed class RevokeAction : IConsoleCommand
{ {
public string Command => "revokeaction"; public string Command => "revokeaction";
public string Description => "Revokes an action from a player, defaulting to current player"; public string Description => "Revokes an action from a player, defaulting to current player";
public string Help => "revokeaction <actionType> <name or userID, omit for current player>"; public string Help => "revokeaction <actionType> <name or userID, omit for current player>";
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) return; if (player == null) return;
var attachedEntity = player.AttachedEntity; var attachedEntity = player.AttachedEntity;
if (args.Length > 1) if (args.Length > 1)
@@ -29,21 +30,21 @@ namespace Content.Server.Commands.Actions
if (attachedEntity == null) return; if (attachedEntity == null) return;
if (!attachedEntity.TryGetComponent(out ServerActionsComponent? actionsComponent)) if (!attachedEntity.TryGetComponent(out ServerActionsComponent? actionsComponent))
{ {
shell.SendText(player, "user has no actions component"); shell.WriteLine("user has no actions component");
return; return;
} }
var actionTypeRaw = args[0]; var actionTypeRaw = args[0];
if (!Enum.TryParse<ActionType>(actionTypeRaw, out var actionType)) if (!Enum.TryParse<ActionType>(actionTypeRaw, out var actionType))
{ {
shell.SendText(player, "unrecognized ActionType enum value, please" + shell.WriteLine("unrecognized ActionType enum value, please" +
" ensure you used correct casing: " + actionTypeRaw); " ensure you used correct casing: " + actionTypeRaw);
return; return;
} }
var actionMgr = IoCManager.Resolve<ActionManager>(); var actionMgr = IoCManager.Resolve<ActionManager>();
if (!actionMgr.TryGet(actionType, out var action)) if (!actionMgr.TryGet(actionType, out var action))
{ {
shell.SendText(player, "unrecognized actionType " + actionType); shell.WriteLine("unrecognized actionType " + actionType);
return; return;
} }

View File

@@ -1,27 +1,28 @@
#nullable enable #nullable enable
using System; using System;
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.GameObjects.Components.Mobs; using Content.Server.GameObjects.Components.Mobs;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Alert; using Content.Shared.Alert;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Commands.Alerts namespace Content.Server.Commands.Alerts
{ {
[AdminCommand(AdminFlags.Debug)] [AdminCommand(AdminFlags.Debug)]
public sealed class ClearAlert : IClientCommand public sealed class ClearAlert : IConsoleCommand
{ {
public string Command => "clearalert"; public string Command => "clearalert";
public string Description => "Clears an alert for a player, defaulting to current player"; public string Description => "Clears an alert for a player, defaulting to current player";
public string Help => "clearalert <alertType> <name or userID, omit for current player>"; public string Help => "clearalert <alertType> <name or userID, omit for current player>";
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) if (player?.AttachedEntity == null)
{ {
shell.SendText(player, "You don't have an entity."); shell.WriteLine("You don't have an entity.");
return; return;
} }
@@ -35,7 +36,7 @@ namespace Content.Server.Commands.Alerts
if (!attachedEntity.TryGetComponent(out ServerAlertsComponent? alertsComponent)) if (!attachedEntity.TryGetComponent(out ServerAlertsComponent? alertsComponent))
{ {
shell.SendText(player, "user has no alerts component"); shell.WriteLine("user has no alerts component");
return; return;
} }
@@ -43,7 +44,7 @@ namespace Content.Server.Commands.Alerts
var alertMgr = IoCManager.Resolve<AlertManager>(); var alertMgr = IoCManager.Resolve<AlertManager>();
if (!alertMgr.TryGet(Enum.Parse<AlertType>(alertType), out var alert)) if (!alertMgr.TryGet(Enum.Parse<AlertType>(alertType), out var alert))
{ {
shell.SendText(player, "unrecognized alertType " + alertType); shell.WriteLine("unrecognized alertType " + alertType);
return; return;
} }

View File

@@ -1,27 +1,28 @@
#nullable enable #nullable enable
using System; using System;
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.GameObjects.Components.Mobs; using Content.Server.GameObjects.Components.Mobs;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Alert; using Content.Shared.Alert;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Commands.Alerts namespace Content.Server.Commands.Alerts
{ {
[AdminCommand(AdminFlags.Debug)] [AdminCommand(AdminFlags.Debug)]
public sealed class ShowAlert : IClientCommand public sealed class ShowAlert : IConsoleCommand
{ {
public string Command => "showalert"; public string Command => "showalert";
public string Description => "Shows an alert for a player, defaulting to current player"; public string Description => "Shows an alert for a player, defaulting to current player";
public string Help => "showalert <alertType> <severity, -1 if no severity> <name or userID, omit for current player>"; public string Help => "showalert <alertType> <severity, -1 if no severity> <name or userID, omit for current player>";
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) if (player == null)
{ {
shell.SendText(player, "You cannot run this command from the server."); shell.WriteLine("You cannot run this command from the server.");
return; return;
} }
@@ -29,7 +30,7 @@ namespace Content.Server.Commands.Alerts
if (attachedEntity == null) if (attachedEntity == null)
{ {
shell.SendText(player, "You don't have an entity."); shell.WriteLine("You don't have an entity.");
return; return;
} }
@@ -41,7 +42,7 @@ namespace Content.Server.Commands.Alerts
if (!attachedEntity.TryGetComponent(out ServerAlertsComponent? alertsComponent)) if (!attachedEntity.TryGetComponent(out ServerAlertsComponent? alertsComponent))
{ {
shell.SendText(player, "user has no alerts component"); shell.WriteLine("user has no alerts component");
return; return;
} }
@@ -50,12 +51,12 @@ namespace Content.Server.Commands.Alerts
var alertMgr = IoCManager.Resolve<AlertManager>(); var alertMgr = IoCManager.Resolve<AlertManager>();
if (!alertMgr.TryGet(Enum.Parse<AlertType>(alertType), out var alert)) if (!alertMgr.TryGet(Enum.Parse<AlertType>(alertType), out var alert))
{ {
shell.SendText(player, "unrecognized alertType " + alertType); shell.WriteLine("unrecognized alertType " + alertType);
return; return;
} }
if (!short.TryParse(severity, out var sevint)) if (!short.TryParse(severity, out var sevint))
{ {
shell.SendText(player, "invalid severity " + sevint); shell.WriteLine("invalid severity " + sevint);
return; return;
} }
alertsComponent.ShowAlert(alert.AlertType, sevint == -1 ? (short?) null : sevint); alertsComponent.ShowAlert(alert.AlertType, sevint == -1 ? (short?) null : sevint);

View File

@@ -3,8 +3,8 @@ using Content.Server.Administration;
using Content.Server.Atmos; using Content.Server.Atmos;
using Content.Server.GameObjects.Components.Atmos; using Content.Server.GameObjects.Components.Atmos;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -13,23 +13,23 @@ using Robust.Shared.Map;
namespace Content.Server.Commands.Atmos namespace Content.Server.Commands.Atmos
{ {
[AdminCommand(AdminFlags.Debug)] [AdminCommand(AdminFlags.Debug)]
public class AddAtmosCommand : IClientCommand public class AddAtmosCommand : IConsoleCommand
{ {
public string Command => "addatmos"; public string Command => "addatmos";
public string Description => "Adds atmos support to a grid."; public string Description => "Adds atmos support to a grid.";
public string Help => $"{Command} <GridId>"; public string Help => $"{Command} <GridId>";
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length < 1) if (args.Length < 1)
{ {
shell.SendText(player, Help); shell.WriteLine(Help);
return; return;
} }
if (!int.TryParse(args[0], out var id)) 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; return;
} }
@@ -39,7 +39,7 @@ namespace Content.Server.Commands.Atmos
if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp)) if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp))
{ {
shell.SendText(player, $"{gridId} is not a valid grid id."); shell.WriteLine($"{gridId} is not a valid grid id.");
return; return;
} }
@@ -47,19 +47,19 @@ namespace Content.Server.Commands.Atmos
if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid)) if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid))
{ {
shell.SendText(player, "Failed to get grid entity."); shell.WriteLine("Failed to get grid entity.");
return; return;
} }
if (grid.HasComponent<IGridAtmosphereComponent>()) if (grid.HasComponent<IGridAtmosphereComponent>())
{ {
shell.SendText(player, "Grid already has an atmosphere."); shell.WriteLine("Grid already has an atmosphere.");
return; return;
} }
grid.AddComponent<GridAtmosphereComponent>(); grid.AddComponent<GridAtmosphereComponent>();
shell.SendText(player, $"Added atmosphere to grid {id}."); shell.WriteLine($"Added atmosphere to grid {id}.");
} }
} }
} }

View File

@@ -3,8 +3,8 @@ using Content.Server.Administration;
using Content.Server.GameObjects.Components.Atmos; using Content.Server.GameObjects.Components.Atmos;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -14,13 +14,13 @@ using Robust.Shared.Maths;
namespace Content.Server.Commands.Atmos namespace Content.Server.Commands.Atmos
{ {
[AdminCommand(AdminFlags.Debug)] [AdminCommand(AdminFlags.Debug)]
public class AddGasCommand : IClientCommand public class AddGasCommand : IConsoleCommand
{ {
public string Command => "addgas"; public string Command => "addgas";
public string Description => "Adds gas at a certain position."; public string Description => "Adds gas at a certain position.";
public string Help => "addgas <X> <Y> <GridId> <Gas> <moles>"; public string Help => "addgas <X> <Y> <GridId> <Gas> <moles>";
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length < 5) return; if (args.Length < 5) return;
if(!int.TryParse(args[0], out var x) if(!int.TryParse(args[0], out var x)
@@ -35,7 +35,7 @@ namespace Content.Server.Commands.Atmos
if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp)) if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp))
{ {
shell.SendText(player, "Invalid grid ID."); shell.WriteLine("Invalid grid ID.");
return; return;
} }
@@ -43,13 +43,13 @@ namespace Content.Server.Commands.Atmos
if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid)) if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid))
{ {
shell.SendText(player, "Failed to get grid entity."); shell.WriteLine("Failed to get grid entity.");
return; return;
} }
if (!grid.HasComponent<GridAtmosphereComponent>()) if (!grid.HasComponent<GridAtmosphereComponent>())
{ {
shell.SendText(player, "Grid doesn't have an atmosphere."); shell.WriteLine("Grid doesn't have an atmosphere.");
return; return;
} }
@@ -59,13 +59,13 @@ namespace Content.Server.Commands.Atmos
if (tile == null) if (tile == null)
{ {
shell.SendText(player, "Invalid coordinates."); shell.WriteLine("Invalid coordinates.");
return; return;
} }
if (tile.Air == null) if (tile.Air == null)
{ {
shell.SendText(player, "Can't add gas to that tile."); shell.WriteLine("Can't add gas to that tile.");
return; return;
} }

View File

@@ -3,8 +3,8 @@ using Content.Server.Administration;
using Content.Server.Atmos; using Content.Server.Atmos;
using Content.Server.GameObjects.Components.Atmos; using Content.Server.GameObjects.Components.Atmos;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -13,23 +13,23 @@ using Robust.Shared.Map;
namespace Content.Server.Commands.Atmos namespace Content.Server.Commands.Atmos
{ {
[AdminCommand(AdminFlags.Debug)] [AdminCommand(AdminFlags.Debug)]
public class AddUnsimulatedAtmosCommand : IClientCommand public class AddUnsimulatedAtmosCommand : IConsoleCommand
{ {
public string Command => "addunsimulatedatmos"; public string Command => "addunsimulatedatmos";
public string Description => "Adds unimulated atmos support to a grid."; public string Description => "Adds unimulated atmos support to a grid.";
public string Help => $"{Command} <GridId>"; public string Help => $"{Command} <GridId>";
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length < 1) if (args.Length < 1)
{ {
shell.SendText(player, Help); shell.WriteLine(Help);
return; return;
} }
if (!int.TryParse(args[0], out var id)) 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; return;
} }
@@ -39,7 +39,7 @@ namespace Content.Server.Commands.Atmos
if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp)) if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp))
{ {
shell.SendText(player, $"{gridId} is not a valid grid id."); shell.WriteLine($"{gridId} is not a valid grid id.");
return; return;
} }
@@ -47,19 +47,19 @@ namespace Content.Server.Commands.Atmos
if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid)) if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid))
{ {
shell.SendText(player, "Failed to get grid entity."); shell.WriteLine("Failed to get grid entity.");
return; return;
} }
if (grid.HasComponent<IGridAtmosphereComponent>()) if (grid.HasComponent<IGridAtmosphereComponent>())
{ {
shell.SendText(player, "Grid already has an atmosphere."); shell.WriteLine("Grid already has an atmosphere.");
return; return;
} }
grid.AddComponent<UnsimulatedGridAtmosphereComponent>(); grid.AddComponent<UnsimulatedGridAtmosphereComponent>();
shell.SendText(player, $"Added unsimulated atmosphere to grid {id}."); shell.WriteLine($"Added unsimulated atmosphere to grid {id}.");
} }
} }

View File

@@ -1,11 +1,11 @@
#nullable enable #nullable enable
using System; using System;
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.GameObjects.Components.Atmos; using Content.Server.GameObjects.Components.Atmos;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -14,14 +14,15 @@ using Robust.Shared.Map;
namespace Content.Server.Commands.Atmos namespace Content.Server.Commands.Atmos
{ {
[AdminCommand(AdminFlags.Debug)] [AdminCommand(AdminFlags.Debug)]
public class DeleteGasCommand : IClientCommand public class DeleteGasCommand : IConsoleCommand
{ {
public string Command => "deletegas"; public string Command => "deletegas";
public string Description => "Removes all gases from a grid, or just of one type if specified."; public string Description => "Removes all gases from a grid, or just of one type if specified.";
public string Help => $"Usage: {Command} <GridId> <Gas> / {Command} <GridId> / {Command} <Gas> / {Command}"; public string Help => $"Usage: {Command} <GridId> <Gas> / {Command} <GridId> / {Command} <Gas> / {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; GridId gridId;
Gas? gas = null; Gas? gas = null;
@@ -30,13 +31,13 @@ namespace Content.Server.Commands.Atmos
case 0: case 0:
if (player == null) if (player == null)
{ {
shell.SendText(player, "A grid must be specified when the command isn't used by a player."); shell.WriteLine("A grid must be specified when the command isn't used by a player.");
return; return;
} }
if (player.AttachedEntity == null) if (player.AttachedEntity == null)
{ {
shell.SendText(player, "You have no entity to get a grid from."); shell.WriteLine("You have no entity to get a grid from.");
return; return;
} }
@@ -44,7 +45,7 @@ namespace Content.Server.Commands.Atmos
if (gridId == GridId.Invalid) if (gridId == GridId.Invalid)
{ {
shell.SendText(player, "You aren't on a grid to delete gas from."); shell.WriteLine("You aren't on a grid to delete gas from.");
return; return;
} }
@@ -56,13 +57,13 @@ namespace Content.Server.Commands.Atmos
// Argument is a gas // Argument is a gas
if (player == null) if (player == null)
{ {
shell.SendText(player, "A grid id must be specified if not using this command as a player."); shell.WriteLine("A grid id must be specified if not using this command as a player.");
return; return;
} }
if (player.AttachedEntity == null) if (player.AttachedEntity == null)
{ {
shell.SendText(player, "You have no entity from which to get a grid id."); shell.WriteLine("You have no entity from which to get a grid id.");
return; return;
} }
@@ -70,13 +71,13 @@ namespace Content.Server.Commands.Atmos
if (gridId == GridId.Invalid) if (gridId == GridId.Invalid)
{ {
shell.SendText(player, "You aren't on a grid to delete gas from."); shell.WriteLine("You aren't on a grid to delete gas from.");
return; return;
} }
if (!Enum.TryParse<Gas>(args[0], true, out var parsedGas)) if (!Enum.TryParse<Gas>(args[0], true, out var parsedGas))
{ {
shell.SendText(player, $"{args[0]} is not a valid gas name."); shell.WriteLine($"{args[0]} is not a valid gas name.");
return; return;
} }
@@ -89,7 +90,7 @@ namespace Content.Server.Commands.Atmos
if (gridId == GridId.Invalid) if (gridId == GridId.Invalid)
{ {
shell.SendText(player, $"{gridId} is not a valid grid id."); shell.WriteLine($"{gridId} is not a valid grid id.");
return; return;
} }
@@ -99,7 +100,7 @@ namespace Content.Server.Commands.Atmos
{ {
if (!int.TryParse(args[0], out var first)) if (!int.TryParse(args[0], out var first))
{ {
shell.SendText(player, $"{args[0]} is not a valid integer for a grid id."); shell.WriteLine($"{args[0]} is not a valid integer for a grid id.");
return; return;
} }
@@ -107,13 +108,13 @@ namespace Content.Server.Commands.Atmos
if (gridId == GridId.Invalid) if (gridId == GridId.Invalid)
{ {
shell.SendText(player, $"{gridId} is not a valid grid id."); shell.WriteLine($"{gridId} is not a valid grid id.");
return; return;
} }
if (!Enum.TryParse<Gas>(args[1], true, out var parsedGas)) if (!Enum.TryParse<Gas>(args[1], true, out var parsedGas))
{ {
shell.SendText(player, $"{args[1]} is not a valid gas."); shell.WriteLine($"{args[1]} is not a valid gas.");
return; return;
} }
@@ -122,7 +123,7 @@ namespace Content.Server.Commands.Atmos
break; break;
} }
default: default:
shell.SendText(player, Help); shell.WriteLine(Help);
return; return;
} }
@@ -130,7 +131,7 @@ namespace Content.Server.Commands.Atmos
if (!mapManager.TryGetGrid(gridId, out var grid)) 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; return;
} }
@@ -138,13 +139,13 @@ namespace Content.Server.Commands.Atmos
if (!entityManager.TryGetEntity(grid.GridEntityId, out var gridEntity)) if (!entityManager.TryGetEntity(grid.GridEntityId, out var gridEntity))
{ {
shell.SendText(player, $"Grid {gridId} has no entity."); shell.WriteLine($"Grid {gridId} has no entity.");
return; return;
} }
if (!gridEntity.TryGetComponent(out GridAtmosphereComponent? atmosphere)) if (!gridEntity.TryGetComponent(out GridAtmosphereComponent? atmosphere))
{ {
shell.SendText(player, $"Grid {gridId} has no {nameof(GridAtmosphereComponent)}"); shell.WriteLine($"Grid {gridId} has no {nameof(GridAtmosphereComponent)}");
return; return;
} }
@@ -182,11 +183,11 @@ namespace Content.Server.Commands.Atmos
if (gas == null) if (gas == null)
{ {
shell.SendText(player, $"Removed {moles} moles from {tiles} tiles."); shell.WriteLine($"Removed {moles} moles from {tiles} tiles.");
return; return;
} }
shell.SendText(player, $"Removed {moles} moles of gas {gas} from {tiles} tiles."); shell.WriteLine($"Removed {moles} moles of gas {gas} from {tiles} tiles.");
} }
} }

View File

@@ -3,8 +3,8 @@ using Content.Server.Administration;
using Content.Server.GameObjects.Components.Atmos; using Content.Server.GameObjects.Components.Atmos;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -13,13 +13,13 @@ using Robust.Shared.Map;
namespace Content.Server.Commands.Atmos namespace Content.Server.Commands.Atmos
{ {
[AdminCommand(AdminFlags.Debug)] [AdminCommand(AdminFlags.Debug)]
public class FillGas : IClientCommand public class FillGas : IConsoleCommand
{ {
public string Command => "fillgas"; public string Command => "fillgas";
public string Description => "Adds gas to all tiles in a grid."; public string Description => "Adds gas to all tiles in a grid.";
public string Help => "fillgas <GridId> <Gas> <moles>"; public string Help => "fillgas <GridId> <Gas> <moles>";
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length < 3) return; if (args.Length < 3) return;
if(!int.TryParse(args[0], out var id) if(!int.TryParse(args[0], out var id)
@@ -32,7 +32,7 @@ namespace Content.Server.Commands.Atmos
if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp)) if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp))
{ {
shell.SendText(player, "Invalid grid ID."); shell.WriteLine("Invalid grid ID.");
return; return;
} }
@@ -40,13 +40,13 @@ namespace Content.Server.Commands.Atmos
if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid)) if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid))
{ {
shell.SendText(player, "Failed to get grid entity."); shell.WriteLine("Failed to get grid entity.");
return; return;
} }
if (!grid.HasComponent<GridAtmosphereComponent>()) if (!grid.HasComponent<GridAtmosphereComponent>())
{ {
shell.SendText(player, "Grid doesn't have an atmosphere."); shell.WriteLine("Grid doesn't have an atmosphere.");
return; return;
} }

View File

@@ -2,26 +2,26 @@
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.GameObjects.EntitySystems; using Content.Server.GameObjects.EntitySystems;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
namespace Content.Server.Commands.Atmos namespace Content.Server.Commands.Atmos
{ {
[AdminCommand(AdminFlags.Debug)] [AdminCommand(AdminFlags.Debug)]
public class ListGasesCommand : IClientCommand public class ListGasesCommand : IConsoleCommand
{ {
public string Command => "listgases"; public string Command => "listgases";
public string Description => "Prints a list of gases and their indices."; public string Description => "Prints a list of gases and their indices.";
public string Help => "listgases"; public string Help => "listgases";
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var atmosSystem = EntitySystem.Get<AtmosphereSystem>(); var atmosSystem = EntitySystem.Get<AtmosphereSystem>();
foreach (var gasPrototype in atmosSystem.Gases) foreach (var gasPrototype in atmosSystem.Gases)
{ {
shell.SendText(player, $"{gasPrototype.Name} ID: {gasPrototype.ID}"); shell.WriteLine($"{gasPrototype.Name} ID: {gasPrototype.ID}");
} }
} }
} }

View File

@@ -2,8 +2,8 @@
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.GameObjects.Components.Atmos; using Content.Server.GameObjects.Components.Atmos;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -13,13 +13,13 @@ using Robust.Shared.Maths;
namespace Content.Server.Commands.Atmos namespace Content.Server.Commands.Atmos
{ {
[AdminCommand(AdminFlags.Debug)] [AdminCommand(AdminFlags.Debug)]
public class RemoveGasCommand : IClientCommand public class RemoveGasCommand : IConsoleCommand
{ {
public string Command => "removegas"; public string Command => "removegas";
public string Description => "Removes an amount of gases."; public string Description => "Removes an amount of gases.";
public string Help => "removegas <X> <Y> <GridId> <amount> <ratio>\nIf <ratio> is true, amount will be treated as the ratio of gas to be removed."; public string Help => "removegas <X> <Y> <GridId> <amount> <ratio>\nIf <ratio> is true, amount will be treated as the ratio of gas to be removed.";
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length < 5) return; if (args.Length < 5) return;
if(!int.TryParse(args[0], out var x) if(!int.TryParse(args[0], out var x)
@@ -34,7 +34,7 @@ namespace Content.Server.Commands.Atmos
if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp)) if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp))
{ {
shell.SendText(player, "Invalid grid ID."); shell.WriteLine("Invalid grid ID.");
return; return;
} }
@@ -42,13 +42,13 @@ namespace Content.Server.Commands.Atmos
if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid)) if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid))
{ {
shell.SendText(player, "Failed to get grid entity."); shell.WriteLine("Failed to get grid entity.");
return; return;
} }
if (!grid.HasComponent<GridAtmosphereComponent>()) if (!grid.HasComponent<GridAtmosphereComponent>())
{ {
shell.SendText(player, "Grid doesn't have an atmosphere."); shell.WriteLine("Grid doesn't have an atmosphere.");
return; return;
} }
@@ -58,13 +58,13 @@ namespace Content.Server.Commands.Atmos
if (tile == null) if (tile == null)
{ {
shell.SendText(player, "Invalid coordinates."); shell.WriteLine("Invalid coordinates.");
return; return;
} }
if (tile.Air == null) if (tile.Air == null)
{ {
shell.SendText(player, "Can't remove gas from that tile."); shell.WriteLine("Can't remove gas from that tile.");
return; return;
} }

View File

@@ -3,8 +3,8 @@ using Content.Server.Administration;
using Content.Server.GameObjects.Components.Atmos; using Content.Server.GameObjects.Components.Atmos;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -13,13 +13,13 @@ using Robust.Shared.Map;
namespace Content.Server.Commands.Atmos namespace Content.Server.Commands.Atmos
{ {
[AdminCommand(AdminFlags.Debug)] [AdminCommand(AdminFlags.Debug)]
public class SetAtmosTemperatureCommand : IClientCommand public class SetAtmosTemperatureCommand : IConsoleCommand
{ {
public string Command => "setatmostemp"; public string Command => "setatmostemp";
public string Description => "Sets a grid's temperature (in kelvin)."; public string Description => "Sets a grid's temperature (in kelvin).";
public string Help => "Usage: setatmostemp <GridId> <Temperature>"; public string Help => "Usage: setatmostemp <GridId> <Temperature>";
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length < 2) return; if (args.Length < 2) return;
if(!int.TryParse(args[0], out var id) if(!int.TryParse(args[0], out var id)
@@ -31,13 +31,13 @@ namespace Content.Server.Commands.Atmos
if (temperature < Atmospherics.TCMB) if (temperature < Atmospherics.TCMB)
{ {
shell.SendText(player, "Invalid temperature."); shell.WriteLine("Invalid temperature.");
return; return;
} }
if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp)) if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp))
{ {
shell.SendText(player, "Invalid grid ID."); shell.WriteLine("Invalid grid ID.");
return; return;
} }
@@ -45,13 +45,13 @@ namespace Content.Server.Commands.Atmos
if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid)) if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid))
{ {
shell.SendText(player, "Failed to get grid entity."); shell.WriteLine("Failed to get grid entity.");
return; return;
} }
if (!grid.HasComponent<GridAtmosphereComponent>()) if (!grid.HasComponent<GridAtmosphereComponent>())
{ {
shell.SendText(player, "Grid doesn't have an atmosphere."); shell.WriteLine("Grid doesn't have an atmosphere.");
return; return;
} }
@@ -69,7 +69,7 @@ namespace Content.Server.Commands.Atmos
tile.Invalidate(); tile.Invalidate();
} }
shell.SendText(player, $"Changed the temperature of {tiles} tiles."); shell.WriteLine($"Changed the temperature of {tiles} tiles.");
} }
} }
} }

View File

@@ -3,8 +3,8 @@ using Content.Server.Administration;
using Content.Server.GameObjects.Components.Atmos; using Content.Server.GameObjects.Components.Atmos;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -14,13 +14,13 @@ using Robust.Shared.Maths;
namespace Content.Server.Commands.Atmos namespace Content.Server.Commands.Atmos
{ {
[AdminCommand(AdminFlags.Debug)] [AdminCommand(AdminFlags.Debug)]
public class SetTemperatureCommand : IClientCommand public class SetTemperatureCommand : IConsoleCommand
{ {
public string Command => "settemp"; public string Command => "settemp";
public string Description => "Sets a tile's temperature (in kelvin)."; public string Description => "Sets a tile's temperature (in kelvin).";
public string Help => "Usage: settemp <X> <Y> <GridId> <Temperature>"; public string Help => "Usage: settemp <X> <Y> <GridId> <Temperature>";
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length < 4) return; if (args.Length < 4) return;
if(!int.TryParse(args[0], out var x) if(!int.TryParse(args[0], out var x)
@@ -34,13 +34,13 @@ namespace Content.Server.Commands.Atmos
if (temperature < Atmospherics.TCMB) if (temperature < Atmospherics.TCMB)
{ {
shell.SendText(player, "Invalid temperature."); shell.WriteLine("Invalid temperature.");
return; return;
} }
if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp)) if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp))
{ {
shell.SendText(player, "Invalid grid ID."); shell.WriteLine("Invalid grid ID.");
return; return;
} }
@@ -48,13 +48,13 @@ namespace Content.Server.Commands.Atmos
if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid)) if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid))
{ {
shell.SendText(player, "Failed to get grid entity."); shell.WriteLine("Failed to get grid entity.");
return; return;
} }
if (!grid.HasComponent<GridAtmosphereComponent>()) if (!grid.HasComponent<GridAtmosphereComponent>())
{ {
shell.SendText(player, "Grid doesn't have an atmosphere."); shell.WriteLine("Grid doesn't have an atmosphere.");
return; return;
} }
@@ -64,13 +64,13 @@ namespace Content.Server.Commands.Atmos
if (tile == null) if (tile == null)
{ {
shell.SendText(player, "Invalid coordinates."); shell.WriteLine("Invalid coordinates.");
return; return;
} }
if (tile.Air == null) if (tile.Air == null)
{ {
shell.SendText(player, "Can't change that tile's temperature."); shell.WriteLine("Can't change that tile's temperature.");
return; return;
} }

View File

@@ -1,32 +1,33 @@
#nullable enable #nullable enable
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.GameObjects.EntitySystems.Atmos; using Content.Server.GameObjects.EntitySystems.Atmos;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
namespace Content.Server.Commands.Atmos namespace Content.Server.Commands.Atmos
{ {
[AdminCommand(AdminFlags.Debug)] [AdminCommand(AdminFlags.Debug)]
public class ShowAtmos : IClientCommand public class ShowAtmos : IConsoleCommand
{ {
public string Command => "showatmos"; public string Command => "showatmos";
public string Description => "Toggles seeing atmos debug overlay."; public string Description => "Toggles seeing atmos debug overlay.";
public string Help => $"Usage: {Command}"; 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) if (player == null)
{ {
shell.SendText(player, "You must be a player to use this command."); shell.WriteLine("You must be a player to use this command.");
return; return;
} }
var atmosDebug = EntitySystem.Get<AtmosDebugOverlaySystem>(); var atmosDebug = EntitySystem.Get<AtmosDebugOverlaySystem>();
var enabled = atmosDebug.ToggleObserver(player); var enabled = atmosDebug.ToggleObserver(player);
shell.SendText(player, enabled shell.WriteLine(enabled
? "Enabled the atmospherics debug overlay." ? "Enabled the atmospherics debug overlay."
: "Disabled the atmospherics debug overlay."); : "Disabled the atmospherics debug overlay.");
} }

View File

@@ -1,11 +1,11 @@
#nullable enable #nullable enable
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.GameObjects.Components.Body.Part; using Content.Server.GameObjects.Components.Body.Part;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.GameObjects.Components.Body; using Content.Shared.GameObjects.Components.Body;
using Content.Shared.GameObjects.Components.Body.Part; using Content.Shared.GameObjects.Components.Body.Part;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -13,14 +13,15 @@ using Robust.Shared.IoC;
namespace Content.Server.Commands namespace Content.Server.Commands
{ {
[AdminCommand(AdminFlags.Fun)] [AdminCommand(AdminFlags.Fun)]
public class AttachBodyPartCommand : IClientCommand public class AttachBodyPartCommand : IConsoleCommand
{ {
public string Command => "attachbodypart"; public string Command => "attachbodypart";
public string Description => "Attaches a body part to you or someone else."; public string Description => "Attaches a body part to you or someone else.";
public string Help => $"{Command} <partEntityUid> / {Command} <entityUid> <partEntityUid>"; public string Help => $"{Command} <partEntityUid> / {Command} <entityUid> <partEntityUid>";
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var player = shell.Player as IPlayerSession;
var entityManager = IoCManager.Resolve<IEntityManager>(); var entityManager = IoCManager.Resolve<IEntityManager>();
IEntity entity; IEntity entity;
@@ -31,19 +32,19 @@ namespace Content.Server.Commands
case 1: case 1:
if (player == null) if (player == null)
{ {
shell.SendText(player, $"You need to specify an entity to attach the part to if you aren't a player.\n{Help}"); shell.WriteLine($"You need to specify an entity to attach the part to if you aren't a player.\n{Help}");
return; return;
} }
if (player.AttachedEntity == null) if (player.AttachedEntity == null)
{ {
shell.SendText(player, $"You need to specify an entity to attach the part to if you aren't attached to an entity.\n{Help}"); shell.WriteLine($"You need to specify an entity to attach the part to if you aren't attached to an entity.\n{Help}");
return; return;
} }
if (!EntityUid.TryParse(args[0], out partUid)) if (!EntityUid.TryParse(args[0], out partUid))
{ {
shell.SendText(player, $"{args[0]} is not a valid entity uid."); shell.WriteLine($"{args[0]} is not a valid entity uid.");
return; return;
} }
@@ -53,50 +54,50 @@ namespace Content.Server.Commands
case 2: case 2:
if (!EntityUid.TryParse(args[0], out var entityUid)) if (!EntityUid.TryParse(args[0], out var entityUid))
{ {
shell.SendText(player, $"{args[0]} is not a valid entity uid."); shell.WriteLine($"{args[0]} is not a valid entity uid.");
return; return;
} }
if (!EntityUid.TryParse(args[1], out partUid)) if (!EntityUid.TryParse(args[1], out partUid))
{ {
shell.SendText(player, $"{args[1]} is not a valid entity uid."); shell.WriteLine($"{args[1]} is not a valid entity uid.");
return; return;
} }
if (!entityManager.TryGetEntity(entityUid, out var tempEntity)) if (!entityManager.TryGetEntity(entityUid, out var tempEntity))
{ {
shell.SendText(player, $"{entityUid} is not a valid entity."); shell.WriteLine($"{entityUid} is not a valid entity.");
return; return;
} }
entity = tempEntity; entity = tempEntity;
break; break;
default: default:
shell.SendText(player, Help); shell.WriteLine(Help);
return; return;
} }
if (!entity.TryGetComponent(out IBody? body)) if (!entity.TryGetComponent(out IBody? body))
{ {
shell.SendText(player, $"Entity {entity.Name} with uid {entity.Uid} does not have a {nameof(IBody)} component."); shell.WriteLine($"Entity {entity.Name} with uid {entity.Uid} does not have a {nameof(IBody)} component.");
return; return;
} }
if (!entityManager.TryGetEntity(partUid, out var partEntity)) if (!entityManager.TryGetEntity(partUid, out var partEntity))
{ {
shell.SendText(player, $"{partUid} is not a valid entity."); shell.WriteLine($"{partUid} is not a valid entity.");
return; return;
} }
if (!partEntity.TryGetComponent(out IBodyPart? part)) if (!partEntity.TryGetComponent(out IBodyPart? part))
{ {
shell.SendText(player, $"Entity {partEntity.Name} with uid {args[0]} does not have a {nameof(IBodyPart)} component."); shell.WriteLine($"Entity {partEntity.Name} with uid {args[0]} does not have a {nameof(IBodyPart)} component.");
return; return;
} }
if (body.HasPart(part)) if (body.HasPart(part))
{ {
shell.SendText(player, $"Body part {partEntity.Name} with uid {partEntity.Uid} is already attached to entity {entity.Name} with uid {entity.Uid}"); shell.WriteLine($"Body part {partEntity.Name} with uid {partEntity.Uid} is already attached to entity {entity.Name} with uid {entity.Uid}");
return; return;
} }

View File

@@ -1,10 +1,10 @@
#nullable enable #nullable enable
using Content.Server.Administration; using Content.Server.Administration;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.GameObjects.Components.Body; using Content.Shared.GameObjects.Components.Body;
using Content.Shared.GameObjects.Components.Body.Part; using Content.Shared.GameObjects.Components.Body.Part;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Random; using Robust.Shared.Interfaces.Random;
@@ -15,7 +15,7 @@ using Robust.Shared.Random;
namespace Content.Server.Commands.Body namespace Content.Server.Commands.Body
{ {
[AdminCommand(AdminFlags.Fun)] [AdminCommand(AdminFlags.Fun)]
class AddHandCommand : IClientCommand class AddHandCommand : IConsoleCommand
{ {
public const string DefaultHandPrototype = "LeftHandHuman"; public const string DefaultHandPrototype = "LeftHandHuman";
@@ -23,11 +23,12 @@ namespace Content.Server.Commands.Body
public string Description => "Adds a hand to your entity."; public string Description => "Adds a hand to your entity.";
public string Help => $"Usage: {Command} <entityUid> <handPrototypeId> / {Command} <entityUid> / {Command} <handPrototypeId> / {Command}"; public string Help => $"Usage: {Command} <entityUid> <handPrototypeId> / {Command} <entityUid> / {Command} <handPrototypeId> / {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 (args.Length > 1) if (args.Length > 1)
{ {
shell.SendText(player, Help); shell.WriteLine(Help);
return; return;
} }
@@ -43,13 +44,13 @@ namespace Content.Server.Commands.Body
{ {
if (player == null) if (player == null)
{ {
shell.SendText(player, "Only a player can run this command without arguments."); shell.WriteLine("Only a player can run this command without arguments.");
return; return;
} }
if (player.AttachedEntity == null) if (player.AttachedEntity == null)
{ {
shell.SendText(player, "You don't have an entity to add a hand to."); shell.WriteLine("You don't have an entity to add a hand to.");
return; return;
} }
@@ -63,7 +64,7 @@ namespace Content.Server.Commands.Body
{ {
if (!entityManager.TryGetEntity(uid, out var parsedEntity)) if (!entityManager.TryGetEntity(uid, out var parsedEntity))
{ {
shell.SendText(player, $"No entity found with uid {uid}"); shell.WriteLine($"No entity found with uid {uid}");
return; return;
} }
@@ -74,14 +75,13 @@ namespace Content.Server.Commands.Body
{ {
if (player == null) if (player == null)
{ {
shell.SendText(player, shell.WriteLine("You must specify an entity to add a hand to when using this command from the server terminal.");
"You must specify an entity to add a hand to when using this command from the server terminal.");
return; return;
} }
if (player.AttachedEntity == null) if (player.AttachedEntity == null)
{ {
shell.SendText(player, "You don't have an entity to add a hand to."); shell.WriteLine("You don't have an entity to add a hand to.");
return; return;
} }
@@ -95,13 +95,13 @@ namespace Content.Server.Commands.Body
{ {
if (!EntityUid.TryParse(args[0], out var uid)) if (!EntityUid.TryParse(args[0], out var uid))
{ {
shell.SendText(player, $"{args[0]} is not a valid entity uid."); shell.WriteLine($"{args[0]} is not a valid entity uid.");
return; return;
} }
if (!entityManager.TryGetEntity(uid, out var parsedEntity)) if (!entityManager.TryGetEntity(uid, out var parsedEntity))
{ {
shell.SendText(player, $"No entity exists with uid {uid}."); shell.WriteLine($"No entity exists with uid {uid}.");
return; return;
} }
@@ -109,7 +109,7 @@ namespace Content.Server.Commands.Body
if (!prototypeManager.HasIndex<EntityPrototype>(args[1])) if (!prototypeManager.HasIndex<EntityPrototype>(args[1]))
{ {
shell.SendText(player, $"No hand entity exists with id {args[1]}."); shell.WriteLine($"No hand entity exists with id {args[1]}.");
return; return;
} }
@@ -119,7 +119,7 @@ namespace Content.Server.Commands.Body
} }
default: default:
{ {
shell.SendText(player, Help); shell.WriteLine(Help);
return; return;
} }
} }
@@ -129,13 +129,13 @@ namespace Content.Server.Commands.Body
var random = IoCManager.Resolve<IRobustRandom>(); var random = IoCManager.Resolve<IRobustRandom>();
var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}"; var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}";
shell.SendText(player, text); shell.WriteLine(text);
return; return;
} }
if (!hand.TryGetComponent(out IBodyPart? part)) if (!hand.TryGetComponent(out IBodyPart? part))
{ {
shell.SendText(player, $"Hand entity {hand} does not have a {nameof(IBodyPart)} component."); shell.WriteLine($"Hand entity {hand} does not have a {nameof(IBodyPart)} component.");
return; return;
} }
@@ -144,7 +144,7 @@ namespace Content.Server.Commands.Body
? $"Added hand to entity {entity.Name}" ? $"Added hand to entity {entity.Name}"
: $"Error occurred trying to add a hand to entity {entity.Name}"; : $"Error occurred trying to add a hand to entity {entity.Name}";
shell.SendText(player, response); shell.WriteLine(response);
} }
} }
} }

View File

@@ -1,9 +1,9 @@
#nullable enable #nullable enable
using Content.Server.Administration; using Content.Server.Administration;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.GameObjects.Components.Body; using Content.Shared.GameObjects.Components.Body;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.Interfaces.Random; using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Random; using Robust.Shared.Random;
@@ -11,29 +11,30 @@ using Robust.Shared.Random;
namespace Content.Server.Commands.Body namespace Content.Server.Commands.Body
{ {
[AdminCommand(AdminFlags.Fun)] [AdminCommand(AdminFlags.Fun)]
class DestroyMechanismCommand : IClientCommand class DestroyMechanismCommand : IConsoleCommand
{ {
public string Command => "destroymechanism"; public string Command => "destroymechanism";
public string Description => "Destroys a mechanism from your entity"; public string Description => "Destroys a mechanism from your entity";
public string Help => $"Usage: {Command} <mechanism>"; public string Help => $"Usage: {Command} <mechanism>";
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) if (player == null)
{ {
shell.SendText(player, "Only a player can run this command."); shell.WriteLine("Only a player can run this command.");
return; return;
} }
if (args.Length == 0) if (args.Length == 0)
{ {
shell.SendText(player, Help); shell.WriteLine(Help);
return; return;
} }
if (player.AttachedEntity == null) if (player.AttachedEntity == null)
{ {
shell.SendText(player, "You have no entity."); shell.WriteLine("You have no entity.");
return; return;
} }
@@ -42,7 +43,7 @@ namespace Content.Server.Commands.Body
var random = IoCManager.Resolve<IRobustRandom>(); var random = IoCManager.Resolve<IRobustRandom>();
var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}"; var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}";
shell.SendText(player, text); shell.WriteLine(text);
return; return;
} }
@@ -54,12 +55,12 @@ namespace Content.Server.Commands.Body
if (mechanism.Name.ToLowerInvariant() == mechanismName) if (mechanism.Name.ToLowerInvariant() == mechanismName)
{ {
part.DeleteMechanism(mechanism); part.DeleteMechanism(mechanism);
shell.SendText(player, $"Mechanism with name {mechanismName} has been destroyed."); shell.WriteLine($"Mechanism with name {mechanismName} has been destroyed.");
return; return;
} }
} }
shell.SendText(player, $"No mechanism was found with name {mechanismName}."); shell.WriteLine($"No mechanism was found with name {mechanismName}.");
} }
} }
} }

View File

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

View File

@@ -1,22 +1,23 @@
#nullable enable #nullable enable
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.Interfaces.Chat; using Content.Server.Interfaces.Chat;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Commands.Chat namespace Content.Server.Commands.Chat
{ {
[AdminCommand(AdminFlags.Admin)] [AdminCommand(AdminFlags.Admin)]
internal class AdminChatCommand : IClientCommand internal class AdminChatCommand : IConsoleCommand
{ {
public string Command => "asay"; public string Command => "asay";
public string Description => "Send chat messages to the private admin chat channel."; public string Description => "Send chat messages to the private admin chat channel.";
public string Help => "asay <text>"; public string Help => "asay <text>";
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 (args.Length < 1) if (args.Length < 1)
return; return;

View File

@@ -1,26 +1,27 @@
#nullable enable #nullable enable
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.Interfaces.Chat; using Content.Server.Interfaces.Chat;
using Content.Server.Players; using Content.Server.Players;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums; using Robust.Shared.Enums;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Commands.Chat namespace Content.Server.Commands.Chat
{ {
[AnyCommand] [AnyCommand]
internal class MeCommand : IClientCommand internal class MeCommand : IConsoleCommand
{ {
public string Command => "me"; public string Command => "me";
public string Description => "Perform an action."; public string Description => "Perform an action.";
public string Help => "me <text>"; public string Help => "me <text>";
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) if (player == null)
{ {
shell.SendText(player, "This command cannot be run from the server."); shell.WriteLine("This command cannot be run from the server.");
return; return;
} }
@@ -39,7 +40,7 @@ namespace Content.Server.Commands.Chat
if (mindComponent == null) if (mindComponent == null)
{ {
shell.SendText(player, "You don't have a mind!"); shell.WriteLine("You don't have a mind!");
return; return;
} }

View File

@@ -1,21 +1,22 @@
#nullable enable #nullable enable
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.Interfaces.Chat; using Content.Server.Interfaces.Chat;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Commands.Chat namespace Content.Server.Commands.Chat
{ {
[AnyCommand] [AnyCommand]
internal class OOCCommand : IClientCommand internal class OOCCommand : IConsoleCommand
{ {
public string Command => "ooc"; public string Command => "ooc";
public string Description => "Send Out Of Character chat messages."; public string Description => "Send Out Of Character chat messages.";
public string Help => "ooc <text>"; public string Help => "ooc <text>";
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 (args.Length < 1) if (args.Length < 1)
return; return;

View File

@@ -1,27 +1,28 @@
#nullable enable #nullable enable
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.GameObjects.Components.Observer; using Content.Server.GameObjects.Components.Observer;
using Content.Server.Interfaces.Chat; using Content.Server.Interfaces.Chat;
using Content.Server.Players; using Content.Server.Players;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums; using Robust.Shared.Enums;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Commands.Chat namespace Content.Server.Commands.Chat
{ {
[AnyCommand] [AnyCommand]
internal class SayCommand : IClientCommand internal class SayCommand : IConsoleCommand
{ {
public string Command => "say"; public string Command => "say";
public string Description => "Send chat messages to the local channel or a specified radio channel."; public string Description => "Send chat messages to the local channel or a specified radio channel.";
public string Help => "say <text>"; public string Help => "say <text>";
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) if (player == null)
{ {
shell.SendText(player, "This command cannot be run from the server."); shell.WriteLine("This command cannot be run from the server.");
return; return;
} }
@@ -40,7 +41,7 @@ namespace Content.Server.Commands.Chat
if (playerEntity == null) if (playerEntity == null)
{ {
shell.SendText(player, "You don't have an entity!"); shell.WriteLine("You don't have an entity!");
return; return;
} }
@@ -52,7 +53,7 @@ namespace Content.Server.Commands.Chat
if (mindComponent == null) if (mindComponent == null)
{ {
shell.SendText(player, "You don't have a mind!"); shell.WriteLine("You don't have a mind!");
return; return;
} }

View File

@@ -1,4 +1,4 @@
#nullable enable #nullable enable
using System; using System;
using System.Linq; using System.Linq;
using Content.Server.Administration; using Content.Server.Administration;
@@ -12,8 +12,8 @@ using Content.Server.Utility;
using Content.Shared.Damage; using Content.Shared.Damage;
using Content.Shared.GameObjects.Components.Damage; using Content.Shared.GameObjects.Components.Damage;
using Content.Shared.Interfaces; using Content.Shared.Interfaces;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums; using Robust.Shared.Enums;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -22,7 +22,7 @@ using Robust.Shared.Localization;
namespace Content.Server.Commands.Chat namespace Content.Server.Commands.Chat
{ {
[AnyCommand] [AnyCommand]
internal class SuicideCommand : IClientCommand internal class SuicideCommand : IConsoleCommand
{ {
public string Command => "suicide"; public string Command => "suicide";
@@ -56,11 +56,12 @@ namespace Content.Server.Commands.Chat
} }
} }
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) if (player == null)
{ {
shell.SendText(player, "You cannot run this command from the server."); shell.WriteLine("You cannot run this command from the server.");
return; return;
} }
@@ -72,7 +73,7 @@ namespace Content.Server.Commands.Chat
if (owner == null) if (owner == null)
{ {
shell.SendText(player, "You don't have a mind!"); shell.WriteLine("You don't have a mind!");
return; return;
} }
@@ -122,7 +123,7 @@ namespace Content.Server.Commands.Chat
// Prevent the player from returning to the body. Yes, this is an ugly hack. // Prevent the player from returning to the body. Yes, this is an ugly hack.
var ghost = new Ghost(){CanReturn = false}; var ghost = new Ghost(){CanReturn = false};
ghost.Execute(shell, player, Array.Empty<string>()); ghost.Execute(shell, argStr, Array.Empty<string>());
} }
} }
} }

View File

@@ -1,8 +1,9 @@
#nullable enable #nullable enable
using System; using System;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using Robust.Server.Interfaces.Console; using Robust.Server.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Network; using Robust.Shared.Network;
@@ -26,11 +27,11 @@ namespace Content.Server.Commands
if (Guid.TryParse(usernameOrId, out var targetGuid)) if (Guid.TryParse(usernameOrId, out var targetGuid))
{ {
if (plyMgr.TryGetSessionById(new NetUserId(targetGuid), out session)) return true; if (plyMgr.TryGetSessionById(new NetUserId(targetGuid), out session)) return true;
shell.SendText(performer, "Unable to find user with that name/id."); shell.WriteLine("Unable to find user with that name/id.");
return false; return false;
} }
shell.SendText(performer, "Unable to find user with that name/id."); shell.WriteLine("Unable to find user with that name/id.");
return false; return false;
} }
@@ -45,7 +46,7 @@ namespace Content.Server.Commands
if (!TryGetSessionByUsernameOrId(shell, usernameOrId, performer, out var session)) return false; if (!TryGetSessionByUsernameOrId(shell, usernameOrId, performer, out var session)) return false;
if (session.AttachedEntity == null) if (session.AttachedEntity == null)
{ {
shell.SendText(performer, "User has no attached entity."); shell.WriteLine("User has no attached entity.");
return false; return false;
} }

View File

@@ -1,8 +1,9 @@
#nullable enable #nullable enable
using Content.Server.Administration; using Content.Server.Administration;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console; using Robust.Server.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
namespace Content.Server.Commands.Damage namespace Content.Server.Commands.Damage
{ {
@@ -13,15 +14,16 @@ namespace Content.Server.Commands.Damage
public override string Description => "Adds a damage flag to your entity or another."; public override string Description => "Adds a damage flag to your entity or another.";
public override string Help => $"Usage: {Command} <flag> / {Command} <entityUid> <flag>"; public override string Help => $"Usage: {Command} <flag> / {Command} <entityUid> <flag>";
public override void Execute(IConsoleShell shell, IPlayerSession? player, string[] args) public override void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var player = shell.Player as IPlayerSession;
if (!TryGetEntity(shell, player, args, true, out var entity, out var flag, out var damageable)) if (!TryGetEntity(shell, player, args, true, out var entity, out var flag, out var damageable))
{ {
return; return;
} }
damageable.AddFlag(flag); damageable.AddFlag(flag);
shell.SendText(player, $"Added damage flag {flag} to entity {entity.Name}"); shell.WriteLine($"Added damage flag {flag} to entity {entity.Name}");
} }
} }
} }

View File

@@ -2,21 +2,21 @@
using System; using System;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using Content.Shared.GameObjects.Components.Damage; using Content.Shared.GameObjects.Components.Damage;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Commands.Damage namespace Content.Server.Commands.Damage
{ {
public abstract class DamageFlagCommand : IClientCommand public abstract class DamageFlagCommand : IConsoleCommand
{ {
public abstract string Command { get; } public abstract string Command { get; }
public abstract string Description { get; } public abstract string Description { get; }
public abstract string Help { get; } public abstract string Help { get; }
public abstract void Execute(IConsoleShell shell, IPlayerSession? player, string[] args); public abstract void Execute(IConsoleShell shell, string argStr, string[] args);
public bool TryGetEntity( public bool TryGetEntity(
IConsoleShell shell, IConsoleShell shell,
@@ -41,19 +41,19 @@ namespace Content.Server.Commands.Damage
{ {
if (player == null) if (player == null)
{ {
shell.SendText(player, "An entity needs to be specified when the command isn't used by a player."); shell.WriteLine("An entity needs to be specified when the command isn't used by a player.");
return false; return false;
} }
if (player.AttachedEntity == null) if (player.AttachedEntity == null)
{ {
shell.SendText(player, "An entity needs to be specified when you aren't attached to an entity."); shell.WriteLine("An entity needs to be specified when you aren't attached to an entity.");
return false; return false;
} }
if (!Enum.TryParse(args[0], true, out parsedFlag)) if (!Enum.TryParse(args[0], true, out parsedFlag))
{ {
shell.SendText(player, $"{args[0]} is not a valid damage flag."); shell.WriteLine($"{args[0]} is not a valid damage flag.");
return false; return false;
} }
@@ -65,44 +65,44 @@ namespace Content.Server.Commands.Damage
{ {
if (!EntityUid.TryParse(args[0], out var id)) if (!EntityUid.TryParse(args[0], out var id))
{ {
shell.SendText(player, $"{args[0]} isn't a valid entity id."); shell.WriteLine($"{args[0]} isn't a valid entity id.");
return false; return false;
} }
var entityManager = IoCManager.Resolve<IEntityManager>(); var entityManager = IoCManager.Resolve<IEntityManager>();
if (!entityManager.TryGetEntity(id, out parsedEntity)) if (!entityManager.TryGetEntity(id, out parsedEntity))
{ {
shell.SendText(player, $"No entity found with id {id}."); shell.WriteLine($"No entity found with id {id}.");
return false; return false;
} }
if (!Enum.TryParse(args[1], true, out parsedFlag)) if (!Enum.TryParse(args[1], true, out parsedFlag))
{ {
shell.SendText(player, $"{args[1]} is not a valid damage flag."); shell.WriteLine($"{args[1]} is not a valid damage flag.");
return false; return false;
} }
break; break;
} }
default: default:
shell.SendText(player, Help); shell.WriteLine(Help);
return false; return false;
} }
if (!parsedEntity.TryGetComponent(out parsedDamageable)) if (!parsedEntity.TryGetComponent(out parsedDamageable))
{ {
shell.SendText(player, $"Entity {parsedEntity.Name} doesn't have a {nameof(IDamageableComponent)}"); shell.WriteLine($"Entity {parsedEntity.Name} doesn't have a {nameof(IDamageableComponent)}");
return false; return false;
} }
if (parsedDamageable.HasFlag(parsedFlag) && adding) if (parsedDamageable.HasFlag(parsedFlag) && adding)
{ {
shell.SendText(player, $"Entity {parsedEntity.Name} already has damage flag {parsedFlag}."); shell.WriteLine($"Entity {parsedEntity.Name} already has damage flag {parsedFlag}.");
return false; return false;
} }
else if (!parsedDamageable.HasFlag(parsedFlag) && !adding) else if (!parsedDamageable.HasFlag(parsedFlag) && !adding)
{ {
shell.SendText(player, $"Entity {parsedEntity.Name} doesn't have damage flag {parsedFlag}."); shell.WriteLine($"Entity {parsedEntity.Name} doesn't have damage flag {parsedFlag}.");
return false; return false;
} }

View File

@@ -1,9 +1,9 @@
#nullable enable #nullable enable
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.GameObjects.EntitySystems; using Content.Server.GameObjects.EntitySystems;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
@@ -12,14 +12,15 @@ using Robust.Shared.IoC;
namespace Content.Server.Commands.Damage namespace Content.Server.Commands.Damage
{ {
[AdminCommand(AdminFlags.Admin)] [AdminCommand(AdminFlags.Admin)]
public class GodModeCommand : IClientCommand public class GodModeCommand : IConsoleCommand
{ {
public string Command => "godmode"; public string Command => "godmode";
public string Description => "Makes your entity or another invulnerable to almost anything. May have irreversible changes."; public string Description => "Makes your entity or another invulnerable to almost anything. May have irreversible changes.";
public string Help => $"Usage: {Command} / {Command} <entityUid>"; public string Help => $"Usage: {Command} / {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;
IEntity entity; IEntity entity;
switch (args.Length) switch (args.Length)
@@ -27,13 +28,13 @@ namespace Content.Server.Commands.Damage
case 0: case 0:
if (player == null) if (player == null)
{ {
shell.SendText(player, "An entity needs to be specified when the command isn't used by a player."); shell.WriteLine("An entity needs to be specified when the command isn't used by a player.");
return; return;
} }
if (player.AttachedEntity == null) if (player.AttachedEntity == null)
{ {
shell.SendText(player, "An entity needs to be specified when you aren't attached to an entity."); shell.WriteLine("An entity needs to be specified when you aren't attached to an entity.");
return; return;
} }
@@ -42,28 +43,28 @@ namespace Content.Server.Commands.Damage
case 1: case 1:
if (!EntityUid.TryParse(args[0], out var id)) if (!EntityUid.TryParse(args[0], out var id))
{ {
shell.SendText(player, $"{args[0]} isn't a valid entity id."); shell.WriteLine($"{args[0]} isn't a valid entity id.");
return; return;
} }
var entityManager = IoCManager.Resolve<IEntityManager>(); var entityManager = IoCManager.Resolve<IEntityManager>();
if (!entityManager.TryGetEntity(id, out var parsedEntity)) if (!entityManager.TryGetEntity(id, out var parsedEntity))
{ {
shell.SendText(player, $"No entity found with id {id}."); shell.WriteLine($"No entity found with id {id}.");
return; return;
} }
entity = parsedEntity; entity = parsedEntity;
break; break;
default: default:
shell.SendText(player, Help); shell.WriteLine(Help);
return; return;
} }
var godmodeSystem = EntitySystem.Get<GodmodeSystem>(); var godmodeSystem = EntitySystem.Get<GodmodeSystem>();
var enabled = godmodeSystem.ToggleGodmode(entity); var enabled = godmodeSystem.ToggleGodmode(entity);
shell.SendText(player, enabled shell.WriteLine(enabled
? $"Enabled godmode for entity {entity.Name} with id {entity.Uid}" ? $"Enabled godmode for entity {entity.Name} with id {entity.Uid}"
: $"Disabled godmode for entity {entity.Name} with id {entity.Uid}"); : $"Disabled godmode for entity {entity.Name} with id {entity.Uid}");
} }

View File

@@ -1,8 +1,9 @@
#nullable enable #nullable enable
using Content.Server.Administration; using Content.Server.Administration;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console; using Robust.Server.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
namespace Content.Server.Commands.Damage namespace Content.Server.Commands.Damage
{ {
@@ -13,15 +14,16 @@ namespace Content.Server.Commands.Damage
public override string Description => "Removes a damage flag from your entity or another."; public override string Description => "Removes a damage flag from your entity or another.";
public override string Help => $"Usage: {Command} <flag> / {Command} <entityUid> <flag>"; public override string Help => $"Usage: {Command} <flag> / {Command} <entityUid> <flag>";
public override void Execute(IConsoleShell shell, IPlayerSession? player, string[] args) public override void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var player = shell.Player as IPlayerSession;
if (!TryGetEntity(shell, player, args, false, out var entity, out var flag, out var damageable)) if (!TryGetEntity(shell, player, args, false, out var entity, out var flag, out var damageable))
{ {
return; return;
} }
damageable.RemoveFlag(flag); damageable.RemoveFlag(flag);
shell.SendText(player, $"Removed damage flag {flag} from entity {entity.Name}"); shell.WriteLine($"Removed damage flag {flag} from entity {entity.Name}");
} }
} }
} }

View File

@@ -1,9 +1,9 @@
#nullable enable #nullable enable
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.GameObjects.Components.Disposal; using Content.Server.GameObjects.Components.Disposal;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -12,42 +12,43 @@ using Robust.Shared.Localization;
namespace Content.Server.Commands.Disposal namespace Content.Server.Commands.Disposal
{ {
[AdminCommand(AdminFlags.Debug)] [AdminCommand(AdminFlags.Debug)]
public class TubeConnectionsCommand : IClientCommand public class TubeConnectionsCommand : IConsoleCommand
{ {
public string Command => "tubeconnections"; public string Command => "tubeconnections";
public string Description => Loc.GetString("Shows all the directions that a tube can connect in."); public string Description => Loc.GetString("Shows all the directions that a tube can connect in.");
public string Help => $"Usage: {Command} <entityUid>"; 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) 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; return;
} }
if (args.Length < 1) if (args.Length < 1)
{ {
shell.SendText(player, Help); shell.WriteLine(Help);
return; return;
} }
if (!EntityUid.TryParse(args[0], out var id)) 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; return;
} }
var entityManager = IoCManager.Resolve<IEntityManager>(); var entityManager = IoCManager.Resolve<IEntityManager>();
if (!entityManager.TryGetEntity(id, out var entity)) 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; return;
} }
if (!entity.TryGetComponent(out IDisposalTubeComponent? tube)) 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; return;
} }

View File

@@ -3,8 +3,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using Content.Server.Administration; using Content.Server.Administration;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -12,17 +12,17 @@ using Robust.Shared.IoC;
namespace Content.Server.Commands namespace Content.Server.Commands
{ {
[AdminCommand(AdminFlags.Mapping)] [AdminCommand(AdminFlags.Mapping)]
public class FindEntitiesWithComponents : IClientCommand public class FindEntitiesWithComponents : IConsoleCommand
{ {
public string Command => "findentitieswithcomponents"; public string Command => "findentitieswithcomponents";
public string Description => "Finds entities with all of the specified components."; public string Description => "Finds entities with all of the specified components.";
public string Help => $"{Command} <componentName1> <componentName2>..."; public string Help => $"{Command} <componentName1> <componentName2>...";
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length == 0) if (args.Length == 0)
{ {
shell.SendText(player, $"Invalid amount of arguments: {args.Length}.\n{Help}"); shell.WriteLine($"Invalid amount of arguments: {args.Length}.\n{Help}");
return; return;
} }
@@ -43,7 +43,7 @@ namespace Content.Server.Commands
if (invalidArgs.Count > 0) if (invalidArgs.Count > 0)
{ {
shell.SendText(player, $"No component found for component names: {string.Join(", ", invalidArgs)}"); shell.WriteLine($"No component found for component names: {string.Join(", ", invalidArgs)}");
return; return;
} }
@@ -63,11 +63,11 @@ namespace Content.Server.Commands
if (entityIds.Count == 0) if (entityIds.Count == 0)
{ {
shell.SendText(player, $"No entities found with components {string.Join(", ", args)}."); shell.WriteLine($"No entities found with components {string.Join(", ", args)}.");
return; return;
} }
shell.SendText(player, $"{entityIds.Count} entities found:\n{string.Join("\n", entityIds)}"); shell.WriteLine($"{entityIds.Count} entities found:\n{string.Join("\n", entityIds)}");
} }
} }
} }

View File

@@ -3,51 +3,51 @@ using Content.Server.Administration;
using Content.Server.GameTicking; using Content.Server.GameTicking;
using Content.Server.Interfaces.GameTicking; using Content.Server.Interfaces.GameTicking;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Commands.GameTicking namespace Content.Server.Commands.GameTicking
{ {
[AdminCommand(AdminFlags.Server)] [AdminCommand(AdminFlags.Server)]
class DelayStartCommand : IClientCommand class DelayStartCommand : IConsoleCommand
{ {
public string Command => "delaystart"; public string Command => "delaystart";
public string Description => "Delays the round start."; public string Description => "Delays the round start.";
public string Help => $"Usage: {Command} <seconds>\nPauses/Resumes the countdown if no argument is provided."; public string Help => $"Usage: {Command} <seconds>\nPauses/Resumes the countdown if no argument is provided.";
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var ticker = IoCManager.Resolve<IGameTicker>(); var ticker = IoCManager.Resolve<IGameTicker>();
if (ticker.RunLevel != GameRunLevel.PreRoundLobby) if (ticker.RunLevel != GameRunLevel.PreRoundLobby)
{ {
shell.SendText(player, "This can only be executed while the game is in the pre-round lobby."); shell.WriteLine("This can only be executed while the game is in the pre-round lobby.");
return; return;
} }
if (args.Length == 0) if (args.Length == 0)
{ {
var paused = ticker.TogglePause(); var paused = ticker.TogglePause();
shell.SendText(player, paused ? "Paused the countdown." : "Resumed the countdown."); shell.WriteLine(paused ? "Paused the countdown." : "Resumed the countdown.");
return; return;
} }
if (args.Length != 1) if (args.Length != 1)
{ {
shell.SendText(player, "Need zero or one arguments."); shell.WriteLine("Need zero or one arguments.");
return; return;
} }
if (!uint.TryParse(args[0], out var seconds) || seconds == 0) if (!uint.TryParse(args[0], out var seconds) || seconds == 0)
{ {
shell.SendText(player, $"{args[0]} isn't a valid amount of seconds."); shell.WriteLine($"{args[0]} isn't a valid amount of seconds.");
return; return;
} }
var time = TimeSpan.FromSeconds(seconds); var time = TimeSpan.FromSeconds(seconds);
if (!ticker.DelayStart(time)) if (!ticker.DelayStart(time))
{ {
shell.SendText(player, "An unknown error has occurred."); shell.WriteLine("An unknown error has occurred.");
} }
} }
} }

View File

@@ -3,26 +3,26 @@ using Content.Server.Administration;
using Content.Server.GameTicking; using Content.Server.GameTicking;
using Content.Server.Interfaces.GameTicking; using Content.Server.Interfaces.GameTicking;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Commands.GameTicking namespace Content.Server.Commands.GameTicking
{ {
[AdminCommand(AdminFlags.Server)] [AdminCommand(AdminFlags.Server)]
class EndRoundCommand : IClientCommand class EndRoundCommand : IConsoleCommand
{ {
public string Command => "endround"; public string Command => "endround";
public string Description => "Ends the round and moves the server to PostRound."; public string Description => "Ends the round and moves the server to PostRound.";
public string Help => String.Empty; public string Help => String.Empty;
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var ticker = IoCManager.Resolve<IGameTicker>(); var ticker = IoCManager.Resolve<IGameTicker>();
if (ticker.RunLevel != GameRunLevel.InRound) if (ticker.RunLevel != GameRunLevel.InRound)
{ {
shell.SendText(player, "This can only be executed while the game is in a round."); shell.WriteLine("This can only be executed while the game is in a round.");
return; return;
} }

View File

@@ -2,43 +2,43 @@
using Content.Server.GameTicking; using Content.Server.GameTicking;
using Content.Server.Interfaces.GameTicking; using Content.Server.Interfaces.GameTicking;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Commands.GameTicking namespace Content.Server.Commands.GameTicking
{ {
[AdminCommand(AdminFlags.Server)] [AdminCommand(AdminFlags.Server)]
class ForcePresetCommand : IClientCommand class ForcePresetCommand : IConsoleCommand
{ {
public string Command => "forcepreset"; public string Command => "forcepreset";
public string Description => "Forces a specific game preset to start for the current lobby."; public string Description => "Forces a specific game preset to start for the current lobby.";
public string Help => $"Usage: {Command} <preset>"; public string Help => $"Usage: {Command} <preset>";
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var ticker = IoCManager.Resolve<IGameTicker>(); var ticker = IoCManager.Resolve<IGameTicker>();
if (ticker.RunLevel != GameRunLevel.PreRoundLobby) if (ticker.RunLevel != GameRunLevel.PreRoundLobby)
{ {
shell.SendText(player, "This can only be executed while the game is in the pre-round lobby."); shell.WriteLine("This can only be executed while the game is in the pre-round lobby.");
return; return;
} }
if (args.Length != 1) if (args.Length != 1)
{ {
shell.SendText(player, "Need exactly one argument."); shell.WriteLine("Need exactly one argument.");
return; return;
} }
var name = args[0]; var name = args[0];
if (!ticker.TryGetPreset(name, out var type)) if (!ticker.TryGetPreset(name, out var type))
{ {
shell.SendText(player, $"No preset exists with name {name}."); shell.WriteLine($"No preset exists with name {name}.");
return; return;
} }
ticker.SetStartPreset(type, true); ticker.SetStartPreset(type, true);
shell.SendText(player, $"Forced the game to start with preset {name}."); shell.WriteLine($"Forced the game to start with preset {name}.");
} }
} }
} }

View File

@@ -4,8 +4,8 @@ using Content.Server.Administration;
using Content.Server.Interfaces.GameTicking; using Content.Server.Interfaces.GameTicking;
using Content.Shared; using Content.Shared;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.Interfaces.Configuration; using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
@@ -13,12 +13,12 @@ using Robust.Shared.Localization;
namespace Content.Server.Commands.GameTicking namespace Content.Server.Commands.GameTicking
{ {
[AdminCommand(AdminFlags.Server)] [AdminCommand(AdminFlags.Server)]
public class GoLobbyCommand : IClientCommand public class GoLobbyCommand : IConsoleCommand
{ {
public string Command => "golobby"; public string Command => "golobby";
public string Description => "Enables the lobby and restarts the round."; public string Description => "Enables the lobby and restarts the round.";
public string Help => $"Usage: {Command} / {Command} <preset>"; public string Help => $"Usage: {Command} / {Command} <preset>";
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
Type? preset = null; Type? preset = null;
var presetName = string.Join(" ", args); var presetName = string.Join(" ", args);
@@ -29,7 +29,7 @@ namespace Content.Server.Commands.GameTicking
{ {
if (!ticker.TryGetPreset(presetName, out preset)) if (!ticker.TryGetPreset(presetName, out preset))
{ {
shell.SendText(player, $"No preset found with name {presetName}"); shell.WriteLine($"No preset found with name {presetName}");
return; return;
} }
} }
@@ -44,7 +44,7 @@ namespace Content.Server.Commands.GameTicking
ticker.SetStartPreset(preset); ticker.SetStartPreset(preset);
} }
shell.SendText(player, $"Enabling the lobby and restarting the round.{(preset == null ? "" : $"\nPreset set to {presetName}")}"); shell.WriteLine($"Enabling the lobby and restarting the round.{(preset == null ? "" : $"\nPreset set to {presetName}")}");
} }
} }
} }

View File

@@ -1,17 +1,17 @@
using System.Collections.Generic; using System.Collections.Generic;
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.GameTicking; using Content.Server.GameTicking;
using Content.Server.Interfaces.GameTicking; using Content.Server.Interfaces.GameTicking;
using Content.Shared.Roles; using Content.Shared.Roles;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
namespace Content.Server.Commands.GameTicking namespace Content.Server.Commands.GameTicking
{ {
[AnyCommand] [AnyCommand]
class JoinGameCommand : IClientCommand class JoinGameCommand : IConsoleCommand
{ {
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
@@ -23,8 +23,9 @@ namespace Content.Server.Commands.GameTicking
{ {
IoCManager.InjectDependencies(this); IoCManager.InjectDependencies(this);
} }
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var player = shell.Player as IPlayerSession;
var output = string.Join(".", args); var output = string.Join(".", args);
if (player == null) if (player == null)
{ {
@@ -34,7 +35,7 @@ namespace Content.Server.Commands.GameTicking
var ticker = IoCManager.Resolve<IGameTicker>(); var ticker = IoCManager.Resolve<IGameTicker>();
if (ticker.RunLevel == GameRunLevel.PreRoundLobby) if (ticker.RunLevel == GameRunLevel.PreRoundLobby)
{ {
shell.SendText(player, "Round has not started."); shell.WriteLine("Round has not started.");
return; return;
} }
else if(ticker.RunLevel == GameRunLevel.InRound) else if(ticker.RunLevel == GameRunLevel.InRound)
@@ -45,7 +46,7 @@ namespace Content.Server.Commands.GameTicking
if(positions.GetValueOrDefault(ID, 0) == 0) //n < 0 is treated as infinite if(positions.GetValueOrDefault(ID, 0) == 0) //n < 0 is treated as infinite
{ {
var jobPrototype = _prototypeManager.Index<JobPrototype>(ID); var jobPrototype = _prototypeManager.Index<JobPrototype>(ID);
shell.SendText(player, $"{jobPrototype.Name} has no available slots."); shell.WriteLine($"{jobPrototype.Name} has no available slots.");
return; return;
} }
ticker.MakeJoinGame(player, args[0].ToString()); ticker.MakeJoinGame(player, args[0].ToString());

View File

@@ -1,9 +1,9 @@
using System.Linq; using System.Linq;
using Content.Server.Administration; using Content.Server.Administration;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Server.Interfaces.Timing; using Robust.Server.Interfaces.Timing;
using Robust.Shared.Console;
using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Utility; using Robust.Shared.Utility;
@@ -11,17 +11,18 @@ using Robust.Shared.Utility;
namespace Content.Server.Commands.GameTicking namespace Content.Server.Commands.GameTicking
{ {
[AdminCommand(AdminFlags.Server | AdminFlags.Mapping)] [AdminCommand(AdminFlags.Server | AdminFlags.Mapping)]
class MappingCommand : IClientCommand class MappingCommand : IConsoleCommand
{ {
public string Command => "mapping"; public string Command => "mapping";
public string Description => "Creates and teleports you to a new uninitialized map for mapping."; public string Description => "Creates and teleports you to a new uninitialized map for mapping.";
public string Help => $"Usage: {Command} <mapname> / {Command} <id> <mapname>"; public string Help => $"Usage: {Command} <mapname> / {Command} <id> <mapname>";
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) if (player == null)
{ {
shell.SendText(player, "Only players can use this command"); shell.WriteLine("Only players can use this command");
return; return;
} }
@@ -34,7 +35,7 @@ namespace Content.Server.Commands.GameTicking
case 1: case 1:
if (player.AttachedEntity == null) if (player.AttachedEntity == null)
{ {
shell.SendText(player, "The map name argument cannot be omitted if you have no entity."); shell.WriteLine("The map name argument cannot be omitted if you have no entity.");
return; return;
} }
@@ -44,7 +45,7 @@ namespace Content.Server.Commands.GameTicking
case 2: case 2:
if (!int.TryParse(args[0], out var id)) 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; return;
} }
@@ -52,21 +53,21 @@ namespace Content.Server.Commands.GameTicking
mapName = args[1]; mapName = args[1];
break; break;
default: default:
shell.SendText(player, Help); shell.WriteLine(Help);
return; return;
} }
shell.ExecuteCommand(player, $"addmap {mapId} false"); shell.ExecuteCommand($"addmap {mapId} false");
shell.ExecuteCommand(player, $"loadbp {mapId} \"{CommandParsing.Escape(mapName)}\" true"); shell.ExecuteCommand($"loadbp {mapId} \"{CommandParsing.Escape(mapName)}\" true");
shell.ExecuteCommand(player, "aghost"); shell.ExecuteCommand("aghost");
shell.ExecuteCommand(player, $"tp 0 0 {mapId}"); shell.ExecuteCommand($"tp 0 0 {mapId}");
var newGrid = mapManager.GetAllGrids().OrderByDescending(g => (int) g.Index).First(); var newGrid = mapManager.GetAllGrids().OrderByDescending(g => (int) g.Index).First();
var pauseManager = IoCManager.Resolve<IPauseManager>(); var pauseManager = IoCManager.Resolve<IPauseManager>();
pauseManager.SetMapPaused(newGrid.ParentMapId, true); pauseManager.SetMapPaused(newGrid.ParentMapId, true);
shell.SendText(player, $"Created unloaded map from file {mapName} with id {mapId}. Use \"savebp {newGrid.Index} foo.yml\" to save the new grid as a map."); shell.WriteLine($"Created unloaded map from file {mapName} with id {mapId}. Use \"savebp {newGrid.Index} foo.yml\" to save the new grid as a map.");
} }
} }
} }

View File

@@ -2,20 +2,20 @@
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.Interfaces.GameTicking; using Content.Server.Interfaces.GameTicking;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Commands.GameTicking namespace Content.Server.Commands.GameTicking
{ {
[AdminCommand(AdminFlags.Server)] [AdminCommand(AdminFlags.Server)]
public class NewRoundCommand : IClientCommand public class NewRoundCommand : IConsoleCommand
{ {
public string Command => "restartround"; public string Command => "restartround";
public string Description => "Moves the server from PostRound to a new PreRoundLobby."; public string Description => "Moves the server from PostRound to a new PreRoundLobby.";
public string Help => String.Empty; public string Help => String.Empty;
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var ticker = IoCManager.Resolve<IGameTicker>(); var ticker = IoCManager.Resolve<IGameTicker>();
ticker.RestartRound(); ticker.RestartRound();

View File

@@ -1,20 +1,21 @@
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.Interfaces.GameTicking; using Content.Server.Interfaces.GameTicking;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Commands.GameTicking namespace Content.Server.Commands.GameTicking
{ {
[AnyCommand] [AnyCommand]
class ObserveCommand : IClientCommand class ObserveCommand : IConsoleCommand
{ {
public string Command => "observe"; public string Command => "observe";
public string Description => ""; public string Description => "";
public string Help => ""; public string Help => "";
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) if (player == null)
{ {
return; return;

View File

@@ -1,23 +1,24 @@
using Content.Server.Interfaces.GameTicking; using Content.Server.Interfaces.GameTicking;
using Content.Server.Players; using Content.Server.Players;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Network; using Robust.Shared.Network;
namespace Content.Server.Commands.GameTicking namespace Content.Server.Commands.GameTicking
{ {
class RespawnCommand : IClientCommand class RespawnCommand : IConsoleCommand
{ {
public string Command => "respawn"; public string Command => "respawn";
public string Description => "Respawns a player, kicking them back to the lobby."; public string Description => "Respawns a player, kicking them back to the lobby.";
public string Help => "respawn [player]"; public string Help => "respawn [player]";
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 (args.Length > 1) if (args.Length > 1)
{ {
shell.SendText(player, "Must provide <= 1 argument."); shell.WriteLine("Must provide <= 1 argument.");
return; return;
} }
@@ -29,7 +30,7 @@ namespace Content.Server.Commands.GameTicking
{ {
if (player == null) if (player == null)
{ {
shell.SendText((IPlayerSession)null, "If not a player, an argument must be given."); shell.WriteLine("If not a player, an argument must be given.");
return; return;
} }
@@ -37,7 +38,7 @@ namespace Content.Server.Commands.GameTicking
} }
else if (!playerMgr.TryGetUserId(args[0], out userId)) else if (!playerMgr.TryGetUserId(args[0], out userId))
{ {
shell.SendText(player, "Unknown player"); shell.WriteLine("Unknown player");
return; return;
} }
@@ -45,13 +46,12 @@ namespace Content.Server.Commands.GameTicking
{ {
if (!playerMgr.TryGetPlayerData(userId, out var data)) if (!playerMgr.TryGetPlayerData(userId, out var data))
{ {
shell.SendText(player, "Unknown player"); shell.WriteLine("Unknown player");
return; return;
} }
data.ContentData().WipeMind(); data.ContentData().WipeMind();
shell.SendText(player, shell.WriteLine("Player is not currently online, but they will respawn if they come back online");
"Player is not currently online, but they will respawn if they come back online");
return; return;
} }

View File

@@ -1,24 +1,24 @@
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.Interfaces.GameTicking; using Content.Server.Interfaces.GameTicking;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Commands.GameTicking namespace Content.Server.Commands.GameTicking
{ {
[AdminCommand(AdminFlags.Server)] [AdminCommand(AdminFlags.Server)]
class SetGamePresetCommand : IClientCommand class SetGamePresetCommand : IConsoleCommand
{ {
public string Command => "setgamepreset"; public string Command => "setgamepreset";
public string Description => ""; public string Description => "";
public string Help => ""; public string Help => "";
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length != 1) if (args.Length != 1)
{ {
shell.SendText(player, "Need exactly one argument."); shell.WriteLine("Need exactly one argument.");
return; return;
} }

View File

@@ -3,26 +3,26 @@ using Content.Server.Administration;
using Content.Server.GameTicking; using Content.Server.GameTicking;
using Content.Server.Interfaces.GameTicking; using Content.Server.Interfaces.GameTicking;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Commands.GameTicking namespace Content.Server.Commands.GameTicking
{ {
[AdminCommand(AdminFlags.Server)] [AdminCommand(AdminFlags.Server)]
class StartRoundCommand : IClientCommand class StartRoundCommand : IConsoleCommand
{ {
public string Command => "startround"; public string Command => "startround";
public string Description => "Ends PreRoundLobby state and starts the round."; public string Description => "Ends PreRoundLobby state and starts the round.";
public string Help => String.Empty; public string Help => String.Empty;
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var ticker = IoCManager.Resolve<IGameTicker>(); var ticker = IoCManager.Resolve<IGameTicker>();
if (ticker.RunLevel != GameRunLevel.PreRoundLobby) if (ticker.RunLevel != GameRunLevel.PreRoundLobby)
{ {
shell.SendText(player, "This can only be executed while the game is in the pre-round lobby."); shell.WriteLine("This can only be executed while the game is in the pre-round lobby.");
return; return;
} }

View File

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

View File

@@ -1,24 +1,24 @@
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.Interfaces.GameTicking; using Content.Server.Interfaces.GameTicking;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Commands.GameTicking namespace Content.Server.Commands.GameTicking
{ {
[AdminCommand(AdminFlags.Server)] [AdminCommand(AdminFlags.Server)]
class ToggleDisallowLateJoinCommand : IClientCommand class ToggleDisallowLateJoinCommand : IConsoleCommand
{ {
public string Command => "toggledisallowlatejoin"; public string Command => "toggledisallowlatejoin";
public string Description => "Allows or disallows latejoining during mid-game."; public string Description => "Allows or disallows latejoining during mid-game.";
public string Help => $"Usage: {Command} <disallow>"; public string Help => $"Usage: {Command} <disallow>";
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length != 1) if (args.Length != 1)
{ {
shell.SendText(player, "Need exactly one argument."); shell.WriteLine("Need exactly one argument.");
return; return;
} }
@@ -27,11 +27,11 @@ namespace Content.Server.Commands.GameTicking
if (bool.TryParse(args[0], out var result)) if (bool.TryParse(args[0], out var result))
{ {
ticker.ToggleDisallowLateJoin(bool.Parse(args[0])); ticker.ToggleDisallowLateJoin(bool.Parse(args[0]));
shell.SendText(player, result ? "Late joining has been disabled." : "Late joining has been enabled."); shell.WriteLine(result ? "Late joining has been disabled." : "Late joining has been enabled.");
} }
else else
{ {
shell.SendText(player, "Invalid argument."); shell.WriteLine("Invalid argument.");
} }
} }
} }

View File

@@ -1,20 +1,21 @@
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.Interfaces.GameTicking; using Content.Server.Interfaces.GameTicking;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Commands.GameTicking namespace Content.Server.Commands.GameTicking
{ {
[AnyCommand] [AnyCommand]
class ToggleReadyCommand : IClientCommand class ToggleReadyCommand : IConsoleCommand
{ {
public string Command => "toggleready"; public string Command => "toggleready";
public string Description => ""; public string Description => "";
public string Help => ""; public string Help => "";
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) if (player == null)
{ {
return; return;

View File

@@ -1,25 +1,26 @@
#nullable enable #nullable enable
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.GameObjects.EntitySystems; using Content.Server.GameObjects.EntitySystems;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
namespace Content.Server.Commands namespace Content.Server.Commands
{ {
[AdminCommand(AdminFlags.Debug)] [AdminCommand(AdminFlags.Debug)]
public class HideContainedContextCommand : IClientCommand public class HideContainedContextCommand : IConsoleCommand
{ {
public string Command => "hidecontainedcontext"; public string Command => "hidecontainedcontext";
public string Description => $"Reverts the effects of {ShowContainedContextCommand.CommandName}"; public string Description => $"Reverts the effects of {ShowContainedContextCommand.CommandName}";
public string Help => $"{Command}"; public string Help => $"{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) if (player == null)
{ {
shell.SendText(player, "You need to be a player to use this command."); shell.WriteLine("You need to be a player to use this command.");
return; return;
} }

View File

@@ -1,37 +1,38 @@
#nullable enable #nullable enable
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.GameObjects.Components.Nutrition; using Content.Server.GameObjects.Components.Nutrition;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.GameObjects.Components.Nutrition; using Content.Shared.GameObjects.Components.Nutrition;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
namespace Content.Server.Commands namespace Content.Server.Commands
{ {
[AdminCommand(AdminFlags.Debug)] [AdminCommand(AdminFlags.Debug)]
public class Hungry : IClientCommand public class Hungry : IConsoleCommand
{ {
public string Command => "hungry"; public string Command => "hungry";
public string Description => "Makes you hungry."; public string Description => "Makes you hungry.";
public string Help => $"{Command}"; public string Help => $"{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) if (player == null)
{ {
shell.SendText(player, "You cannot use this command unless you are a player."); shell.WriteLine("You cannot use this command unless you are a player.");
return; return;
} }
if (player.AttachedEntity == null) if (player.AttachedEntity == null)
{ {
shell.SendText(player, "You cannot use this command without an entity."); shell.WriteLine("You cannot use this command without an entity.");
return; return;
} }
if (!player.AttachedEntity.TryGetComponent(out HungerComponent? hunger)) if (!player.AttachedEntity.TryGetComponent(out HungerComponent? hunger))
{ {
shell.SendText(player, $"Your entity does not have a {nameof(HungerComponent)} component."); shell.WriteLine($"Your entity does not have a {nameof(HungerComponent)} component.");
return; return;
} }

View File

@@ -1,4 +1,4 @@
#nullable enable #nullable enable
using System; using System;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Text; using System.Text;
@@ -6,8 +6,8 @@ using Content.Server.Administration;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Damage; using Content.Shared.Damage;
using Content.Shared.GameObjects.Components.Damage; using Content.Shared.GameObjects.Components.Damage;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -15,7 +15,7 @@ using Robust.Shared.IoC;
namespace Content.Server.Commands namespace Content.Server.Commands
{ {
[AdminCommand(AdminFlags.Fun)] [AdminCommand(AdminFlags.Fun)]
class HurtCommand : IClientCommand class HurtCommand : IConsoleCommand
{ {
public string Command => "hurt"; public string Command => "hurt";
public string Description => "Ouch"; public string Description => "Ouch";
@@ -53,7 +53,7 @@ namespace Content.Server.Commands
if (playerEntity == null) if (playerEntity == null)
{ {
shell.SendText(player, $"You must have a player entity to use this command without specifying an entity.\n{Help}"); shell.WriteLine($"You must have a player entity to use this command without specifying an entity.\n{Help}");
return false; return false;
} }
@@ -63,7 +63,7 @@ namespace Content.Server.Commands
if (!EntityUid.TryParse(arg, out var entityUid)) if (!EntityUid.TryParse(arg, out var entityUid))
{ {
shell.SendText(player, $"{arg} is not a valid entity uid.\n{Help}"); shell.WriteLine($"{arg} is not a valid entity uid.\n{Help}");
return false; return false;
} }
@@ -72,7 +72,7 @@ namespace Content.Server.Commands
if (!entityManager.TryGetEntity(entityUid, out var parsedEntity)) if (!entityManager.TryGetEntity(entityUid, out var parsedEntity))
{ {
shell.SendText(player, $"No entity found with uid {entityUid}"); shell.WriteLine($"No entity found with uid {entityUid}");
return false; return false;
} }
@@ -89,7 +89,7 @@ namespace Content.Server.Commands
{ {
if (!int.TryParse(args[1], out var amount)) if (!int.TryParse(args[1], out var amount))
{ {
shell.SendText(player, $"{args[1]} is not a valid damage integer."); shell.WriteLine($"{args[1]} is not a valid damage integer.");
func = null; func = null;
return false; return false;
@@ -101,20 +101,19 @@ namespace Content.Server.Commands
{ {
if (!damageable.DamageClasses.ContainsKey(damageClass)) if (!damageable.DamageClasses.ContainsKey(damageClass))
{ {
shell.SendText(player, $"Entity {damageable.Owner.Name} with id {damageable.Owner.Uid} can not be damaged with damage class {damageClass}"); shell.WriteLine($"Entity {damageable.Owner.Name} with id {damageable.Owner.Uid} can not be damaged with damage class {damageClass}");
return; return;
} }
if (!damageable.ChangeDamage(damageClass, amount, ignoreResistances)) if (!damageable.ChangeDamage(damageClass, amount, ignoreResistances))
{ {
shell.SendText(player, $"Entity {damageable.Owner.Name} with id {damageable.Owner.Uid} received no damage."); shell.WriteLine($"Entity {damageable.Owner.Name} with id {damageable.Owner.Uid} received no damage.");
return; return;
} }
shell.SendText(player, shell.WriteLine($"Damaged entity {damageable.Owner.Name} with id {damageable.Owner.Uid} for {amount} {damageClass} damage{(ignoreResistances ? ", ignoring resistances." : ".")}");
$"Damaged entity {damageable.Owner.Name} with id {damageable.Owner.Uid} for {amount} {damageClass} damage{(ignoreResistances ? ", ignoring resistances." : ".")}");
}; };
return true; return true;
@@ -126,37 +125,38 @@ namespace Content.Server.Commands
{ {
if (!damageable.DamageTypes.ContainsKey(damageType)) if (!damageable.DamageTypes.ContainsKey(damageType))
{ {
shell.SendText(player, $"Entity {damageable.Owner.Name} with id {damageable.Owner.Uid} can not be damaged with damage class {damageType}"); shell.WriteLine($"Entity {damageable.Owner.Name} with id {damageable.Owner.Uid} can not be damaged with damage class {damageType}");
return; return;
} }
if (!damageable.ChangeDamage(damageType, amount, ignoreResistances)) if (!damageable.ChangeDamage(damageType, amount, ignoreResistances))
{ {
shell.SendText(player, $"Entity {damageable.Owner.Name} with id {damageable.Owner.Uid} received no damage."); shell.WriteLine($"Entity {damageable.Owner.Name} with id {damageable.Owner.Uid} received no damage.");
return; return;
} }
shell.SendText(player, $"Damaged entity {damageable.Owner.Name} with id {damageable.Owner.Uid} for {amount} {damageType} damage{(ignoreResistances ? ", ignoring resistances." : ".")}"); shell.WriteLine($"Damaged entity {damageable.Owner.Name} with id {damageable.Owner.Uid} for {amount} {damageType} damage{(ignoreResistances ? ", ignoring resistances." : ".")}");
}; };
return true; return true;
} }
else else
{ {
shell.SendText(player, $"{args[0]} is not a valid damage class or type."); shell.WriteLine($"{args[0]} is not a valid damage class or type.");
var types = DamageTypes(); var types = DamageTypes();
shell.SendText(player, types); shell.WriteLine(types);
func = null; func = null;
return false; return false;
} }
} }
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var player = shell.Player as IPlayerSession;
bool ignoreResistances; bool ignoreResistances;
IEntity entity; IEntity entity;
Damage? damageFunc; Damage? damageFunc;
@@ -172,12 +172,12 @@ namespace Content.Server.Commands
types = types.Replace('e', 'é'); types = types.Replace('e', 'é');
} }
shell.SendText(player, types); shell.WriteLine(types);
return; return;
// Not enough args // Not enough args
case var n when n < 2: case var n when n < 2:
shell.SendText(player, $"Invalid number of arguments ({args.Length}).\n{Help}"); shell.WriteLine($"Invalid number of arguments ({args.Length}).\n{Help}");
return; return;
case var n when n >= 2 && n <= 4: case var n when n >= 2 && n <= 4:
if (!TryParseDamageArgs(shell, player, args, out damageFunc)) if (!TryParseDamageArgs(shell, player, args, out damageFunc))
@@ -198,7 +198,7 @@ namespace Content.Server.Commands
{ {
if (!bool.TryParse(args[3], out ignoreResistances)) if (!bool.TryParse(args[3], out ignoreResistances))
{ {
shell.SendText(player, $"{args[3]} is not a valid boolean value for ignoreResistances.\n{Help}"); shell.WriteLine($"{args[3]} is not a valid boolean value for ignoreResistances.\n{Help}");
return; return;
} }
} }
@@ -209,13 +209,13 @@ namespace Content.Server.Commands
break; break;
default: default:
shell.SendText(player, $"Invalid amount of arguments ({args.Length}).\n{Help}"); shell.WriteLine($"Invalid amount of arguments ({args.Length}).\n{Help}");
return; return;
} }
if (!entity.TryGetComponent(out IDamageableComponent? damageable)) if (!entity.TryGetComponent(out IDamageableComponent? damageable))
{ {
shell.SendText(player, $"Entity {entity.Name} with id {entity.Uid} does not have a {nameof(IDamageableComponent)}."); shell.WriteLine($"Entity {entity.Name} with id {entity.Uid} does not have a {nameof(IDamageableComponent)}.");
return; return;
} }

View File

@@ -1,24 +1,25 @@
#nullable enable #nullable enable
using System.Linq; using System.Linq;
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.GameObjects.Components; using Content.Server.GameObjects.Components;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.GameObjects; using Robust.Server.Interfaces.GameObjects;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Commands.Interactable namespace Content.Server.Commands.Interactable
{ {
[AdminCommand(AdminFlags.Debug)] [AdminCommand(AdminFlags.Debug)]
class AnchorCommand : IClientCommand class AnchorCommand : IConsoleCommand
{ {
public string Command => "anchor"; public string Command => "anchor";
public string Description => "Anchors all entities in a radius around the user"; public string Description => "Anchors all entities in a radius around the user";
public string Help => $"Usage: {Command} <radius>"; public string Help => $"Usage: {Command} <radius>";
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) if (player?.AttachedEntity == null)
{ {
return; return;
@@ -26,19 +27,19 @@ namespace Content.Server.Commands.Interactable
if (args.Length != 1) if (args.Length != 1)
{ {
shell.SendText(player, Help); shell.WriteLine(Help);
return; return;
} }
if (!int.TryParse(args[0], out var radius)) if (!int.TryParse(args[0], out var radius))
{ {
shell.SendText(player, $"{args[0]} isn't a valid integer."); shell.WriteLine($"{args[0]} isn't a valid integer.");
return; return;
} }
if (radius < 0) if (radius < 0)
{ {
shell.SendText(player, "Radius must be positive."); shell.WriteLine("Radius must be positive.");
return; return;
} }

View File

@@ -1,10 +1,10 @@
#nullable enable #nullable enable
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.GameObjects.Components.Interactable; using Content.Server.GameObjects.Components.Interactable;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Maps; using Content.Shared.Maps;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Map; using Robust.Shared.Map;
@@ -15,14 +15,15 @@ namespace Content.Server.Commands.Interactable
/// <see cref="TilePryingComponent.TryPryTile"/> /// <see cref="TilePryingComponent.TryPryTile"/>
/// </summary> /// </summary>
[AdminCommand(AdminFlags.Debug)] [AdminCommand(AdminFlags.Debug)]
class TilePryCommand : IClientCommand class TilePryCommand : IConsoleCommand
{ {
public string Command => "tilepry"; public string Command => "tilepry";
public string Description => "Pries up all tiles in a radius around the user."; public string Description => "Pries up all tiles in a radius around the user.";
public string Help => $"Usage: {Command} <radius>"; public string Help => $"Usage: {Command} <radius>";
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) if (player?.AttachedEntity == null)
{ {
return; return;
@@ -30,19 +31,19 @@ namespace Content.Server.Commands.Interactable
if (args.Length != 1) if (args.Length != 1)
{ {
shell.SendText(player, Help); shell.WriteLine(Help);
return; return;
} }
if (!int.TryParse(args[0], out var radius)) if (!int.TryParse(args[0], out var radius))
{ {
shell.SendText(player, $"{args[0]} isn't a valid integer."); shell.WriteLine($"{args[0]} isn't a valid integer.");
return; return;
} }
if (radius < 0) if (radius < 0)
{ {
shell.SendText(player, "Radius must be positive."); shell.WriteLine("Radius must be positive.");
return; return;
} }

View File

@@ -1,24 +1,25 @@
#nullable enable #nullable enable
using System.Linq; using System.Linq;
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.GameObjects.Components; using Content.Server.GameObjects.Components;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.GameObjects; using Robust.Server.Interfaces.GameObjects;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Commands.Interactable namespace Content.Server.Commands.Interactable
{ {
[AdminCommand(AdminFlags.Debug)] [AdminCommand(AdminFlags.Debug)]
class UnAnchorCommand : IClientCommand class UnAnchorCommand : IConsoleCommand
{ {
public string Command => "unanchor"; public string Command => "unanchor";
public string Description => "Unanchors all anchorable entities in a radius around the user"; public string Description => "Unanchors all anchorable entities in a radius around the user";
public string Help => $"Usage: {Command} <radius>"; public string Help => $"Usage: {Command} <radius>";
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) if (player?.AttachedEntity == null)
{ {
return; return;
@@ -26,19 +27,19 @@ namespace Content.Server.Commands.Interactable
if (args.Length != 1) if (args.Length != 1)
{ {
shell.SendText(player, Help); shell.WriteLine(Help);
return; return;
} }
if (!int.TryParse(args[0], out var radius)) if (!int.TryParse(args[0], out var radius))
{ {
shell.SendText(player, $"{args[0]} isn't a valid integer."); shell.WriteLine($"{args[0]} isn't a valid integer.");
return; return;
} }
if (radius < 0) if (radius < 0)
{ {
shell.SendText(player, "Radius must be positive."); shell.WriteLine("Radius must be positive.");
return; return;
} }

View File

@@ -1,15 +1,15 @@
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.GameObjects.EntitySystems; using Content.Server.GameObjects.EntitySystems;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Commands.MachineLinking namespace Content.Server.Commands.MachineLinking
{ {
[AdminCommand(AdminFlags.Debug)] [AdminCommand(AdminFlags.Debug)]
public class SignalLinkerCommand : IClientCommand public class SignalLinkerCommand : IConsoleCommand
{ {
public string Command => "signallink"; public string Command => "signallink";
@@ -17,8 +17,9 @@ namespace Content.Server.Commands.MachineLinking
public string Help => "signallink (on/off)"; public string Help => "signallink (on/off)";
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var player = shell.Player as IPlayerSession;
bool? enable = null; bool? enable = null;
if (args.Length > 0) if (args.Length > 0)
{ {
@@ -43,7 +44,7 @@ namespace Content.Server.Commands.MachineLinking
} }
var ret = system.SignalLinkerKeybind(player.UserId, enable); var ret = system.SignalLinkerKeybind(player.UserId, enable);
shell.SendText(player, ret ? "Enabled" : "Disabled"); shell.WriteLine(ret ? "Enabled" : "Disabled");
} }
} }
} }

View File

@@ -3,8 +3,8 @@ using Content.Server.Administration;
using Content.Server.GameObjects.Components.Mobs; using Content.Server.GameObjects.Components.Mobs;
using Content.Server.GameObjects.Components.Movement; using Content.Server.GameObjects.Components.Movement;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -12,23 +12,23 @@ using Robust.Shared.IoC;
namespace Content.Server.Commands namespace Content.Server.Commands
{ {
[AdminCommand(AdminFlags.Fun)] [AdminCommand(AdminFlags.Fun)]
public class MakeSentientCommand : IClientCommand public class MakeSentientCommand : IConsoleCommand
{ {
public string Command => "makesentient"; public string Command => "makesentient";
public string Description => "Makes an entity sentient (able to be controlled by a player)"; public string Description => "Makes an entity sentient (able to be controlled by a player)";
public string Help => "makesentient <entity id>"; public string Help => "makesentient <entity id>";
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length != 1) if (args.Length != 1)
{ {
shell.SendText(player, "Wrong number of arguments."); shell.WriteLine("Wrong number of arguments.");
return; return;
} }
if (!int.TryParse(args[0], out var id)) if (!int.TryParse(args[0], out var id))
{ {
shell.SendText(player, "Invalid argument."); shell.WriteLine("Invalid argument.");
return; return;
} }
@@ -38,7 +38,7 @@ namespace Content.Server.Commands
if (!entityManager.TryGetEntity(entId, out var entity) || entity.Deleted) if (!entityManager.TryGetEntity(entId, out var entity) || entity.Deleted)
{ {
shell.SendText(player, "Invalid entity specified!"); shell.WriteLine("Invalid entity specified!");
return; return;
} }

View File

@@ -3,15 +3,15 @@ using Content.Server.Mobs.Roles;
using Content.Server.Players; using Content.Server.Players;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Roles; using Content.Shared.Roles;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
namespace Content.Server.Commands.Mobs namespace Content.Server.Commands.Mobs
{ {
[AdminCommand(AdminFlags.Fun)] [AdminCommand(AdminFlags.Fun)]
public class AddRoleCommand : IClientCommand public class AddRoleCommand : IConsoleCommand
{ {
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
@@ -21,11 +21,11 @@ namespace Content.Server.Commands.Mobs
public string Help => "addrole <session ID> <Role Type>\nThat role type is the actual C# type name."; public string Help => "addrole <session ID> <Role Type>\nThat role type is the actual C# type name.";
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length != 2) if (args.Length != 2)
{ {
shell.SendText(player, "Expected exactly 2 arguments."); shell.WriteLine("Expected exactly 2 arguments.");
return; return;
} }
@@ -38,7 +38,7 @@ namespace Content.Server.Commands.Mobs
} }
else else
{ {
shell.SendText(player, "Can't find that mind"); shell.WriteLine("Can't find that mind");
} }
} }
} }

View File

@@ -2,14 +2,14 @@
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.Players; using Content.Server.Players;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.Commands.Mobs namespace Content.Server.Commands.Mobs
{ {
[AdminCommand(AdminFlags.Admin)] [AdminCommand(AdminFlags.Admin)]
public class MindInfoCommand : IClientCommand public class MindInfoCommand : IConsoleCommand
{ {
public string Command => "mindinfo"; public string Command => "mindinfo";
@@ -17,11 +17,11 @@ namespace Content.Server.Commands.Mobs
public string Help => "mindinfo <session ID>"; public string Help => "mindinfo <session ID>";
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length != 1) if (args.Length != 1)
{ {
shell.SendText(player, "Expected exactly 1 argument."); shell.WriteLine("Expected exactly 1 argument.");
return; return;
} }
@@ -37,11 +37,11 @@ namespace Content.Server.Commands.Mobs
builder.AppendFormat("{0} ", role.Name); builder.AppendFormat("{0} ", role.Name);
} }
shell.SendText(player, builder.ToString()); shell.WriteLine(builder.ToString());
} }
else else
{ {
shell.SendText(player, "Can't find that mind"); shell.WriteLine("Can't find that mind");
} }
} }
} }

View File

@@ -3,15 +3,15 @@ using Content.Server.Mobs.Roles;
using Content.Server.Players; using Content.Server.Players;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Roles; using Content.Shared.Roles;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
namespace Content.Server.Commands.Mobs namespace Content.Server.Commands.Mobs
{ {
[AdminCommand(AdminFlags.Fun)] [AdminCommand(AdminFlags.Fun)]
public class RemoveRoleCommand : IClientCommand public class RemoveRoleCommand : IConsoleCommand
{ {
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
@@ -21,11 +21,11 @@ namespace Content.Server.Commands.Mobs
public string Help => "rmrole <session ID> <Role Type>\nThat role type is the actual C# type name."; public string Help => "rmrole <session ID> <Role Type>\nThat role type is the actual C# type name.";
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length != 2) if (args.Length != 2)
{ {
shell.SendText(player, "Expected exactly 2 arguments."); shell.WriteLine("Expected exactly 2 arguments.");
return; return;
} }
@@ -38,7 +38,7 @@ namespace Content.Server.Commands.Mobs
} }
else else
{ {
shell.SendText(player, "Can't find that mind"); shell.WriteLine("Can't find that mind");
} }
} }
} }

View File

@@ -1,8 +1,8 @@
using Content.Server.Administration; using Content.Server.Administration;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Interfaces; using Content.Shared.Interfaces;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -10,13 +10,13 @@ using Robust.Shared.IoC;
namespace Content.Server.Commands.Notify namespace Content.Server.Commands.Notify
{ {
[AdminCommand(AdminFlags.Debug)] [AdminCommand(AdminFlags.Debug)]
public class PopupMsgCommand : IClientCommand public class PopupMsgCommand : IConsoleCommand
{ {
public string Command => "srvpopupmsg"; public string Command => "srvpopupmsg";
public string Description => ""; public string Description => "";
public string Help => ""; public string Help => "";
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var entityMgr = IoCManager.Resolve<IEntityManager>(); var entityMgr = IoCManager.Resolve<IEntityManager>();

View File

@@ -3,31 +3,31 @@ using Content.Server.Administration;
using Content.Server.Objectives; using Content.Server.Objectives;
using Content.Server.Players; using Content.Server.Players;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
namespace Content.Server.Commands.Objectives namespace Content.Server.Commands.Objectives
{ {
[AdminCommand(AdminFlags.Admin)] [AdminCommand(AdminFlags.Admin)]
public class AddObjectiveCommand : IClientCommand public class AddObjectiveCommand : IConsoleCommand
{ {
public string Command => "addobjective"; public string Command => "addobjective";
public string Description => "Adds an objective to the player's mind."; public string Description => "Adds an objective to the player's mind.";
public string Help => "addobjective <username> <objectiveID>"; public string Help => "addobjective <username> <objectiveID>";
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length != 2) if (args.Length != 2)
{ {
shell.SendText(player, "Expected exactly 2 arguments."); shell.WriteLine("Expected exactly 2 arguments.");
return; return;
} }
var mgr = IoCManager.Resolve<IPlayerManager>(); var mgr = IoCManager.Resolve<IPlayerManager>();
if (!mgr.TryGetPlayerDataByUsername(args[0], out var data)) if (!mgr.TryGetPlayerDataByUsername(args[0], out var data))
{ {
shell.SendText(player, "Can't find the playerdata."); shell.WriteLine("Can't find the playerdata.");
return; return;
} }
@@ -35,20 +35,20 @@ namespace Content.Server.Commands.Objectives
var mind = data.ContentData()?.Mind; var mind = data.ContentData()?.Mind;
if (mind == null) if (mind == null)
{ {
shell.SendText(player, "Can't find the mind."); shell.WriteLine("Can't find the mind.");
return; return;
} }
if (!IoCManager.Resolve<IPrototypeManager>() if (!IoCManager.Resolve<IPrototypeManager>()
.TryIndex<ObjectivePrototype>(args[1], out var objectivePrototype)) .TryIndex<ObjectivePrototype>(args[1], out var objectivePrototype))
{ {
shell.SendText(player, $"Can't find matching ObjectivePrototype {objectivePrototype}"); shell.WriteLine($"Can't find matching ObjectivePrototype {objectivePrototype}");
return; return;
} }
if (!mind.TryAddObjective(objectivePrototype)) if (!mind.TryAddObjective(objectivePrototype))
{ {
shell.SendText(player, "Objective requirements dont allow that objective to be added."); shell.WriteLine("Objective requirements dont allow that objective to be added.");
} }
} }

Some files were not shown because too many files have changed in this diff Show More