0.3.13: re-hiding follows an admin_overrides.json override of css_hide

This commit is contained in:
Astra 2026-09-29 12:44:15 +01:00
parent 33feda8179
commit 0446fe49e8
2 changed files with 23 additions and 4 deletions

View file

@ -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)
{