Picking a ghostrole as an admin will now deadmin you. (#29790)

* @forcibly deadmins you

* Added checks for AdminDeadminOnJoin
This commit is contained in:
MFMessage
2024-07-11 00:53:14 -05:00
committed by GitHub
parent 1ea7e3e71f
commit 1a50760e67
2 changed files with 14 additions and 1 deletions

View 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)