From 6fc8b015baec0bc5d5a92685c0aa8522d73a6f57 Mon Sep 17 00:00:00 2001 From: Dawid Bepierszcz <41084667+daffyyyy@users.noreply.github.com> Date: Sat, 29 Jun 2024 15:06:32 +0200 Subject: [PATCH] 1.4.8b - Improved admin loading --- CS2-SimpleAdmin.cs | 2 +- Commands/basecommands.cs | 1 - Events.cs | 21 ++++++++++++--------- VERSION | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/CS2-SimpleAdmin.cs b/CS2-SimpleAdmin.cs index 0b1df24..c2f51b5 100644 --- a/CS2-SimpleAdmin.cs +++ b/CS2-SimpleAdmin.cs @@ -39,7 +39,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.8a"; + public override string ModuleVersion => "1.4.8b"; public CS2_SimpleAdminConfig Config { get; set; } = new(); diff --git a/Commands/basecommands.cs b/Commands/basecommands.cs index e744d3c..042751b 100644 --- a/Commands/basecommands.cs +++ b/Commands/basecommands.cs @@ -318,7 +318,6 @@ public void ReloadAdmins(CCSPlayerController? caller) Task.Run(async () => { - await adminManager.CrateGroupsJsonFile(); await adminManager.CreateAdminsJsonFile(); diff --git a/Events.cs b/Events.cs index ec21683..ed307ef 100644 --- a/Events.cs +++ b/Events.cs @@ -22,7 +22,7 @@ private void RegisterEvents() private void OnGameServerSteamAPIActivated() { - AddTimer(8.5f, () => + AddTimer(3.0f, () => { if (ServerId != null || _database == null) return; @@ -44,8 +44,6 @@ private void OnGameServerSteamAPIActivated() Task.Run(async () => { - PermissionManager adminManager = new(_database); - try { await using var connection = await _database.GetConnectionAsync(); @@ -71,10 +69,16 @@ await connection.ExecuteAsync( new { address }); ServerId = serverId; + + if (ServerId != null) + { + Server.NextFrame(() => ReloadAdmins(null)); + } + } catch (Exception ex) { - _logger?.LogCritical("Unable to create or get server_id" + ex.Message); + _logger?.LogCritical("Unable to create or get server_id: " + ex.Message); } if (Config.EnableMetrics) @@ -337,8 +341,8 @@ public HookResult OnCommandTeamSay(CCSPlayerController? player, CommandInfo info public void OnMapStart(string mapName) { - if (Config.ReloadAdminsEveryMapChange) - AddTimer(3.0f, () => ReloadAdmins(null)); + if (Config.ReloadAdminsEveryMapChange && ServerId != null) + AddTimer(2.0f, () => ReloadAdmins(null)); var path = Path.GetDirectoryName(ModuleDirectory); if (Directory.Exists(path + "/CS2-Tags")) @@ -353,6 +357,7 @@ public void OnMapStart(string mapName) _database = new Database.Database(_dbConnectionString); + /* AddTimer(2f, () => { if (ServerId != null) return; @@ -370,8 +375,6 @@ public void OnMapStart(string mapName) Task.Run(async () => { - PermissionManager adminManager = new(_database); - try { await using var connection = await _database.GetConnectionAsync(); @@ -419,7 +422,7 @@ await connection.ExecuteAsync( } }); }); - + */ AddTimer(61.0f, () => { #if DEBUG diff --git a/VERSION b/VERSION index d66eab6..618c21e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.4.7a \ No newline at end of file +1.4.8b \ No newline at end of file