diff --git a/CS2-SimpleAdmin.cs b/CS2-SimpleAdmin.cs index c994c2b..53bf02a 100644 --- a/CS2-SimpleAdmin.cs +++ b/CS2-SimpleAdmin.cs @@ -11,7 +11,7 @@ using System.Collections.Concurrent; namespace CS2_SimpleAdmin; -[MinimumApiVersion(215)] +[MinimumApiVersion(220)] public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig { public static CS2_SimpleAdmin Instance { get; private set; } = new(); @@ -37,7 +37,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig "CS2-SimpleAdmin" + (Helper.IsDebugBuild ? " (DEBUG)" : " (RELEASE)"); public override string ModuleDescription => "Simple admin plugin for Counter-Strike 2 :)"; public override string ModuleAuthor => "daffyy & Dliix66"; - public override string ModuleVersion => "1.4.3c"; + public override string ModuleVersion => "1.4.3d"; public CS2_SimpleAdminConfig Config { get; set; } = new(); diff --git a/Commands/basebans.cs b/Commands/basebans.cs index 8019f1f..c7e7d30 100644 --- a/Commands/basebans.cs +++ b/Commands/basebans.cs @@ -49,8 +49,8 @@ namespace CS2_SimpleAdmin internal void Ban(CCSPlayerController? caller, CCSPlayerController? player, int time, string reason, string? callerName = null, BanManager? banManager = null, CommandInfo? command = null) { if (_database == null || player is null || !player.IsValid) return; - - if (CheckValidBan(caller, time) == false) + + if (CheckValidBan(caller, time) == false) return; callerName ??= caller == null ? "Console" : caller.PlayerName; @@ -145,7 +145,7 @@ namespace CS2_SimpleAdmin public void OnAddBanCommand(CCSPlayerController? caller, CommandInfo command) { if (_database == null) return; - + var callerName = caller == null ? "Console" : caller.PlayerName; if (command.ArgCount < 2) return; @@ -162,8 +162,8 @@ namespace CS2_SimpleAdmin var reason = _localizer?["sa_unknown"] ?? "Unknown"; int.TryParse(command.GetArg(2), out var time); - - if (CheckValidBan(caller, time) == false) + + if (CheckValidBan(caller, time) == false) return; if (command.ArgCount >= 3 && command.GetArg(3).Length > 0) @@ -283,7 +283,7 @@ namespace CS2_SimpleAdmin }; int.TryParse(command.GetArg(2), out var time); - if (CheckValidBan(caller, time) == false) + if (CheckValidBan(caller, time) == false) return; if (command.ArgCount >= 3 && command.GetArg(3).Length > 0) @@ -367,24 +367,26 @@ namespace CS2_SimpleAdmin command.ReplyToCommand($"Banned player with IP address {ipAddress}."); } - + private bool CheckValidBan(CCSPlayerController? caller, int duration) { if (caller == null) return true; - + bool canPermBan = AdminManager.PlayerHasPermissions(caller, "@css/permban"); - - if (duration > Config.MaxBanDuration && canPermBan == false) - { - caller.PrintToChat($"{_localizer!["sa_prefix"]} {_localizer["sa_ban_max_duration_exceeded", Config.MaxBanDuration]}"); - } if (duration == 0 && canPermBan == false) { caller.PrintToChat($"{_localizer!["sa_prefix"]} {_localizer["sa_ban_perm_restricted"]}"); + return false; } - return caller.IsValid && canPermBan; + if (duration > Config.MaxBanDuration && canPermBan == false) + { + caller.PrintToChat($"{_localizer!["sa_prefix"]} {_localizer["sa_ban_max_duration_exceeded", Config.MaxBanDuration]}"); + return false; + } + + return true; } [ConsoleCommand("css_unban")] diff --git a/Commands/basecommands.cs b/Commands/basecommands.cs index 5acc515..c0c5d66 100644 --- a/Commands/basecommands.cs +++ b/Commands/basecommands.cs @@ -319,8 +319,14 @@ namespace CS2_SimpleAdmin await adminManager.CrateGroupsJsonFile(); await adminManager.CreateAdminsJsonFile(); - AdminManager.LoadAdminData(ModuleDirectory + "/data/admins.json"); - AdminManager.LoadAdminGroups(ModuleDirectory + "/data/groups.json"); + await Server.NextFrameAsync(() => + { + AddTimer(0.2f, () => + { + AdminManager.LoadAdminData(ModuleDirectory + "/data/admins.json"); + AdminManager.LoadAdminGroups(ModuleDirectory + "/data/groups.json"); + }); + }); }); //_ = _adminManager.GiveAllGroupsFlags(); diff --git a/VERSION b/VERSION index 6686f25..fb39751 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.4.3c \ No newline at end of file +1.4.3d \ No newline at end of file