2024-05-29 06:00:42 +12:00
|
|
|
using Content.Server.Administration.Managers;
|
2021-12-13 16:45:49 +11:00
|
|
|
using Content.Shared.Administration;
|
2022-08-14 12:54:49 -07:00
|
|
|
using Content.Shared.GameTicking;
|
2021-02-01 16:49:43 -08:00
|
|
|
using Robust.Shared.Console;
|
2020-12-03 03:40:47 +01:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.GameTicking.Commands
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
|
|
|
|
[AnyCommand]
|
2022-02-16 00:23:23 -07:00
|
|
|
sealed class ObserveCommand : IConsoleCommand
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
2024-05-12 17:34:52 -07:00
|
|
|
[Dependency] private readonly IEntityManager _e = default!;
|
2024-05-29 06:00:42 +12:00
|
|
|
[Dependency] private readonly IAdminManager _adminManager = default!;
|
2024-05-12 17:34:52 -07:00
|
|
|
|
2020-12-03 03:40:47 +01:00
|
|
|
public string Command => "observe";
|
|
|
|
|
public string Description => "";
|
|
|
|
|
public string Help => "";
|
|
|
|
|
|
2021-02-01 16:49:43 -08:00
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
2023-10-28 09:59:53 +11:00
|
|
|
if (shell.Player is not { } player)
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
2024-08-11 09:46:57 +00:00
|
|
|
shell.WriteError(Loc.GetString("shell-cannot-run-command-from-server"));
|
2020-12-03 03:40:47 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-12 17:34:52 -07:00
|
|
|
var ticker = _e.System<GameTicker>();
|
2021-12-21 21:23:29 +01:00
|
|
|
|
|
|
|
|
if (ticker.RunLevel == GameRunLevel.PreRoundLobby)
|
|
|
|
|
{
|
|
|
|
|
shell.WriteError("Wait until the round starts.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-29 06:00:42 +12:00
|
|
|
var isAdminCommand = args.Length > 0 && args[0].ToLower() == "admin";
|
|
|
|
|
|
|
|
|
|
if (!isAdminCommand && _adminManager.IsAdmin(player))
|
|
|
|
|
{
|
|
|
|
|
_adminManager.DeAdmin(player);
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-14 12:54:49 -07:00
|
|
|
if (ticker.PlayerGameStatuses.TryGetValue(player.UserId, out var status) &&
|
|
|
|
|
status != PlayerGameStatus.JoinedGame)
|
|
|
|
|
{
|
2023-06-21 13:04:07 +12:00
|
|
|
ticker.JoinAsObserver(player);
|
2022-08-14 12:54:49 -07:00
|
|
|
}
|
2021-11-27 19:28:32 -06:00
|
|
|
else
|
2022-08-14 12:54:49 -07:00
|
|
|
{
|
2021-11-27 19:28:32 -06:00
|
|
|
shell.WriteError($"{player.Name} is not in the lobby. This incident will be reported.");
|
2022-08-14 12:54:49 -07:00
|
|
|
}
|
2020-12-03 03:40:47 +01:00
|
|
|
}
|
|
|
|
|
}
|
2021-02-01 16:49:43 -08:00
|
|
|
}
|