0.3.13: re-hiding follows an admin_overrides.json override of css_hide
This commit is contained in:
parent
33feda8179
commit
083104c6b5
2 changed files with 23 additions and 4 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue