From 0446fe49e8185f821f5490212f0e96014f6e1848 Mon Sep 17 00:00:00 2001 From: Astra Date: Tue, 29 Sep 2026 12:44:15 +0100 Subject: [PATCH] 0.3.13: re-hiding follows an admin_overrides.json override of css_hide --- AdminStealth.cs | 24 +++++++++++++++++++++--- README.md | 3 ++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/AdminStealth.cs b/AdminStealth.cs index 37d0adf..317484c 100644 --- a/AdminStealth.cs +++ b/AdminStealth.cs @@ -23,11 +23,12 @@ namespace AdminStealth; public class AdminStealth : BasePlugin { public override string ModuleName => "AdminStealth"; - public override string ModuleVersion => "0.3.12"; + public override string ModuleVersion => "0.3.13"; public override string ModuleAuthor => "astra"; public override string ModuleDescription => "Makes CS2-SimpleAdmin's css_hide look like leaving, and keeps it"; - // css_hide's own permission. Restoring waits for it, since SimpleAdmin loads admins after connect. + // css_hide's own permission, unless admin_overrides.json overrides css_hide (see CanHide). + // Restoring waits for it, since SimpleAdmin loads admins after connect. private const string HidePermission = "@css/kick"; private const float RestoreDelay = 2f; private const int RestoreAttempts = 5; @@ -310,7 +311,7 @@ public class AdminStealth : BasePlugin return; } - if (AdminManager.PlayerHasPermissions(player, HidePermission)) + if (CanHide(player)) { _restoring.Add(slot); player.ExecuteClientCommandFromServer(_hideAliases[0]); @@ -318,6 +319,23 @@ public class AdminStealth : BasePlugin AddTimer(RestoreDelay, () => TryRestore(slot, steamId, attempt + 1), TimerFlags.STOP_ON_MAPCHANGE); } + // Whether the player may use css_hide: an admin_overrides.json override of it wins, checked the way + // CSS checks the typed command ("all" needs every flag, anything else one of them). + private bool CanHide(CCSPlayerController player) + { + var command = _hideAliases[0]; + var data = AdminManager.GetCommandOverrideData(command); + if (data == null || !data.Enabled) + return AdminManager.PlayerHasPermissions(player, HidePermission); + + var flags = data.Flags.ToArray(); + BaseRequiresPermissions check = data.CheckType == "all" + ? new RequiresPermissions(flags) + : new RequiresPermissionsOr(flags); + check.Command = command; + return check.CanExecuteCommand(player); + } + // For an admin SimpleAdmin still counts as hidden who ended up on a team anyway. private static void MoveOffTeams(CCSPlayerController player) { diff --git a/README.md b/README.md index 4c4e7e6..5f82ae0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # AdminStealth -A companion to CS2-SimpleAdmin's `css_hide` (`!hide`, `@css/kick`). SimpleAdmin's hide moves the +A companion to CS2-SimpleAdmin's `css_hide` (`!hide`, `@css/kick`, or whatever an +`admin_overrides.json` entry for `css_hide` says: reconnect re-hiding follows it too). SimpleAdmin's hide moves the admin off the scoreboard. This plugin makes it look like they left the server: - When an admin hides, every other player gets a `player_disconnect` event for them, sent to each