Skip to content

Commit

Permalink
1.4.8b
Browse files Browse the repository at this point in the history
- Improved admin loading
  • Loading branch information
daffyyyy committed Jun 29, 2024
1 parent 6b5e360 commit 6fc8b01
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CS2-SimpleAdmin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
public override string ModuleName => "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();

Expand Down
1 change: 0 additions & 1 deletion Commands/basecommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ public void ReloadAdmins(CCSPlayerController? caller)

Task.Run(async () =>
{

await adminManager.CrateGroupsJsonFile();
await adminManager.CreateAdminsJsonFile();

Expand Down
21 changes: 12 additions & 9 deletions Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private void RegisterEvents()

private void OnGameServerSteamAPIActivated()
{
AddTimer(8.5f, () =>
AddTimer(3.0f, () =>
{
if (ServerId != null || _database == null) return;

Expand All @@ -44,8 +44,6 @@ private void OnGameServerSteamAPIActivated()

Task.Run(async () =>
{
PermissionManager adminManager = new(_database);

try
{
await using var connection = await _database.GetConnectionAsync();
Expand All @@ -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)
Expand Down Expand Up @@ -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"))
Expand All @@ -353,6 +357,7 @@ public void OnMapStart(string mapName)

_database = new Database.Database(_dbConnectionString);

/*
AddTimer(2f, () =>
{
if (ServerId != null) return;
Expand All @@ -370,8 +375,6 @@ public void OnMapStart(string mapName)
Task.Run(async () =>
{
PermissionManager adminManager = new(_database);

try
{
await using var connection = await _database.GetConnectionAsync();
Expand Down Expand Up @@ -419,7 +422,7 @@ await connection.ExecuteAsync(
}
});
});

*/
AddTimer(61.0f, () =>
{
#if DEBUG
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.7a
1.4.8b

0 comments on commit 6fc8b01

Please sign in to comment.