AdminStealth 0.3.15: no reply to css_hide from players who may not hide

A catch-all command listener stops it before any handler, so CSS's
missing-permission message isn't sent either.
This commit is contained in:
Astra 2026-10-03 00:22:12 +01:00
parent 7eba09905a
commit a74e9946c8
2 changed files with 14 additions and 1 deletions

View file

@ -23,7 +23,7 @@ namespace AdminStealth;
public class AdminStealth : BasePlugin
{
public override string ModuleName => "AdminStealth";
public override string ModuleVersion => "0.3.14";
public override string ModuleVersion => "0.3.15";
public override string ModuleAuthor => "astra";
public override string ModuleDescription => "Makes CS2-SimpleAdmin's css_hide look like leaving, and keeps it";
@ -66,6 +66,9 @@ public class AdminStealth : BasePlugin
// without ever calling us.
foreach (var alias in _hideAliases)
AddCommandListener(alias, (player, command) => OnHideTyped(player, command));
// Players who may not hide get no reply at all, not even CSS's missing-permission one. Only
// a catch-all listener runs before every plugin's command handler, for console and chat.
AddCommandListener(null, OnAnyCommand);
// Joining any team, spectators included, would make SimpleAdmin unhide them.
AddCommandListener("jointeam", (player, command) => OnJoinTeam(player, command));
AddCommandListener("spectate", (player, command) => OnJoinTeam(player, command));
@ -123,6 +126,14 @@ public class AdminStealth : BasePlugin
return player == null ? HookResult.Continue : HookResult.Stop;
}
private HookResult OnAnyCommand(CCSPlayerController? player, CommandInfo command)
{
if (player is not { IsValid: true, IsBot: false } ||
!_hideAliases.Contains(command.GetArg(0), StringComparer.OrdinalIgnoreCase) || CanHide(player))
return HookResult.Continue;
return HookResult.Stop;
}
private HookResult OnHideTyped(CCSPlayerController? player, CommandInfo command)
{
if (player is { IsValid: true } && !_restoring.Contains(player.Slot))