]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Picking a ghostrole as an admin will now deadmin you. (#29790)
authorMFMessage <22904993+MFMessage@users.noreply.github.com>
Thu, 11 Jul 2024 05:53:14 +0000 (00:53 -0500)
committerGitHub <noreply@github.com>
Thu, 11 Jul 2024 05:53:14 +0000 (15:53 +1000)
* @forcibly deadmins you

* Added checks for AdminDeadminOnJoin

Content.Server/Ghost/Roles/GhostRoleSystem.cs
Content.Shared/CCVar/CCVars.cs

index b6627f11540fecbe3181de13bb4f4776d906c6d1..dfb0c8e0865e405f42567883e351367b53e7ddc4 100644 (file)
@@ -31,6 +31,9 @@ using Robust.Shared.Utility;
 using Content.Server.Popups;
 using Content.Shared.Verbs;
 using Robust.Shared.Collections;
+using Content.Server.Administration.Managers;
+using Content.Shared.CCVar;
+using Robust.Shared.Configuration;
 
 namespace Content.Server.Ghost.Roles
 {
@@ -48,6 +51,8 @@ namespace Content.Server.Ghost.Roles
         [Dependency] private readonly IGameTiming _timing = default!;
         [Dependency] private readonly PopupSystem _popupSystem = default!;
         [Dependency] private readonly IPrototypeManager _prototype = default!;
+        [Dependency] private readonly IAdminManager _adminManager = default!;
+        [Dependency] private readonly IConfigurationManager _cfg = default!;
 
         private uint _nextRoleIdentifier;
         private bool _needsUpdateGhostRoleCount = true;
@@ -587,6 +592,14 @@ namespace Content.Server.Ghost.Roles
             // forced into a ghost role.
             LeaveAllRaffles(message.Player);
             CloseEui(message.Player);
+
+            // The player is no longer a ghost, so they should not be adminned anymore. Deadmin them.
+            // Ensures that admins do not forget to deadmin themselves upon entering a ghost role.
+            var autoDeAdmin = _cfg.GetCVar(CCVars.AdminDeadminOnJoin);
+            if (autoDeAdmin && _adminManager.IsAdmin(message.Entity))
+            {
+                _adminManager.DeAdmin(message.Player);
+            }
         }
 
         private void OnMindAdded(EntityUid uid, GhostTakeoverAvailableComponent component, MindAddedMessage args)
index a0e9157e922d9c1388ed11004ff23a4458ecd88f..044a95c4583c4c677a050aa31f199b29ec09c6a3 100644 (file)
@@ -870,7 +870,7 @@ namespace Content.Shared.CCVar
             CVarDef.Create("admin.show_pii_onban", false, CVar.SERVERONLY);
 
         /// <summary>
-        /// If an admin joins a round by reading up or using the late join button, automatically
+        /// If an admin joins a round by readying up or using the late join button, automatically
         /// de-admin them.
         /// </summary>
         public static readonly CVarDef<bool> AdminDeadminOnJoin =