From 64e6d346d62192fca8bd8ec7771fdd5e4ca82c21 Mon Sep 17 00:00:00 2001 From: Kevin Zheng Date: Mon, 31 Jul 2023 12:13:38 -0700 Subject: [PATCH] Add cvar to deadmin when joining round (#18430) --- Content.Server/GameTicking/GameTicker.Spawning.cs | 8 ++++++++ Content.Shared/CCVar/CCVars.cs | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/Content.Server/GameTicking/GameTicker.Spawning.cs b/Content.Server/GameTicking/GameTicker.Spawning.cs index 003512270a..71f27028fa 100644 --- a/Content.Server/GameTicking/GameTicker.Spawning.cs +++ b/Content.Server/GameTicking/GameTicker.Spawning.cs @@ -1,11 +1,13 @@ using System.Globalization; using System.Linq; using System.Numerics; +using Content.Server.Administration.Managers; using Content.Server.Ghost; using Content.Server.Players; using Content.Server.Spawners.Components; using Content.Server.Speech.Components; using Content.Server.Station.Components; +using Content.Shared.CCVar; using Content.Shared.Database; using Content.Shared.GameTicking; using Content.Shared.Preferences; @@ -22,6 +24,8 @@ namespace Content.Server.GameTicking { public sealed partial class GameTicker { + [Dependency] private readonly IAdminManager _adminManager = default!; + private const string ObserverPrototypeName = "MobObserver"; /// @@ -133,6 +137,10 @@ namespace Content.Server.GameTicking return; } + // Automatically de-admin players who are joining. + if (_cfg.GetCVar(CCVars.AdminDeadminOnJoin) && _adminManager.IsAdmin(player)) + _adminManager.DeAdmin(player); + // We raise this event to allow other systems to handle spawning this player themselves. (e.g. late-join wizard, etc) var bev = new PlayerBeforeSpawnEvent(player, character, jobId, lateJoin, station); RaiseLocalEvent(bev); diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index 36b5377566..3c4162106d 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -705,6 +705,13 @@ namespace Content.Shared.CCVar public static readonly CVarDef AdminShowPIIOnBan = CVarDef.Create("admin.show_pii_onban", false, CVar.SERVERONLY); + /// + /// If an admin joins a round by reading up or using the late join button, automatically + /// de-admin them. + /// + public static readonly CVarDef AdminDeadminOnJoin = + CVarDef.Create("admin.deadmin_on_join", false, CVar.SERVERONLY); + /* * Explosions */