diff --git a/CS2-SimpleAdmin/CS2-SimpleAdmin.cs b/CS2-SimpleAdmin/CS2-SimpleAdmin.cs index a2a82ee..83d5856 100644 --- a/CS2-SimpleAdmin/CS2-SimpleAdmin.cs +++ b/CS2-SimpleAdmin/CS2-SimpleAdmin.cs @@ -22,7 +22,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"; - public override string ModuleVersion => "1.8.2b"; + public override string ModuleVersion => "1.8.1a"; public override void Load(bool hotReload) { diff --git a/CS2-SimpleAdmin/Events.cs b/CS2-SimpleAdmin/Events.cs index 8d0149a..26df60c 100644 --- a/CS2-SimpleAdmin/Events.cs +++ b/CS2-SimpleAdmin/Events.cs @@ -253,7 +253,7 @@ public partial class CS2_SimpleAdmin player.DiePosition = null; } - AddTimer(0.5f, () => + AddTimer(0.41f, () => { foreach (var list in RenamedPlayers) { diff --git a/CS2-SimpleAdmin/Managers/CacheManager.cs b/CS2-SimpleAdmin/Managers/CacheManager.cs index d02e036..27bc518 100644 --- a/CS2-SimpleAdmin/Managers/CacheManager.cs +++ b/CS2-SimpleAdmin/Managers/CacheManager.cs @@ -73,7 +73,7 @@ internal class CacheManager: IDisposable if (CS2_SimpleAdmin.Instance.Config.OtherSettings.CheckMultiAccountsByIp) { // Optimization: Load IP history and build cache in single pass - var ipHistory = await connection.QueryAsync( + var ipHistory = await connection.QueryAsync<(ulong steamid, string? name, uint address, DateTime used_at)>( "SELECT steamid, name, address, used_at FROM sa_players_ips ORDER BY steamid, address, used_at DESC"); var unknownName = CS2_SimpleAdmin._localizer?["sa_unknown"] ?? "Unknown"; @@ -84,24 +84,24 @@ internal class CacheManager: IDisposable foreach (var record in ipHistory) { // When we encounter a new steamid, save the previous one - if ((ulong)record.Steamid != currentSteamId && currentSteamId != 0) + if (record.steamid != currentSteamId && currentSteamId != 0) { _playerIpsCache[currentSteamId] = currentIpSet; currentIpSet = new HashSet(new IpRecordComparer()); latestIpTimestamps.Clear(); } - currentSteamId = (ulong)record.Steamid; + currentSteamId = record.steamid; // Only keep the latest timestamp for each IP - if (!latestIpTimestamps.TryGetValue(record.Address, out var existingTimestamp) || - record.Used_at > existingTimestamp) + if (!latestIpTimestamps.TryGetValue(record.address, out var existingTimestamp) || + record.used_at > existingTimestamp) { - latestIpTimestamps[record.Address] = record.Used_at; + latestIpTimestamps[record.address] = record.used_at; currentIpSet.Add(new IpRecord( - record.Address, - record.Used_at, - string.IsNullOrEmpty(record.Name) ? unknownName : record.Name + record.address, + record.used_at, + string.IsNullOrEmpty(record.name) ? unknownName : record.name )); } } @@ -283,23 +283,23 @@ internal class CacheManager: IDisposable if (CS2_SimpleAdmin.Instance.Config.OtherSettings.CheckMultiAccountsByIp) { - var ipHistory = (await connection.QueryAsync( + var ipHistory = (await connection.QueryAsync<(ulong steamid, string? name, uint address, DateTime used_at)>( "SELECT steamid, name, address, used_at FROM sa_players_ips WHERE used_at >= @lastUpdate ORDER BY used_at DESC LIMIT 300", new { lastUpdate = _lastUpdateTime })); - foreach (var group in ipHistory.AsValueEnumerable().GroupBy(x => x.Steamid)) + foreach (var group in ipHistory.AsValueEnumerable().GroupBy(x => x.steamid)) { var ipSet = new HashSet( group - .GroupBy(x => x.Address) + .GroupBy(x => x.address) .Select(g => { - var latest = g.MaxBy(x => x.Used_at); + var latest = g.MaxBy(x => x.used_at); return new IpRecord( g.Key, - latest.Used_at, - !string.IsNullOrEmpty(latest.Name) - ? latest.Name + latest.used_at, + !string.IsNullOrEmpty(latest.name) + ? latest.name : CS2_SimpleAdmin._localizer?["sa_unknown"] ?? "Unknown" ); }), @@ -307,7 +307,7 @@ internal class CacheManager: IDisposable ); _playerIpsCache.AddOrUpdate( - (ulong)group.Key, + group.Key, _ => ipSet, (_, existingSet) => { diff --git a/CS2-SimpleAdmin/Managers/PlayerManager.cs b/CS2-SimpleAdmin/Managers/PlayerManager.cs index 1736112..2f08393 100644 --- a/CS2-SimpleAdmin/Managers/PlayerManager.cs +++ b/CS2-SimpleAdmin/Managers/PlayerManager.cs @@ -275,16 +275,6 @@ internal class PlayerManager /// public void CheckPlayersTimer() { - CS2_SimpleAdmin.Instance.AddTimer(5f, () => - { - foreach (var (steamid, name) in CS2_SimpleAdmin.RenamedPlayers) - { - var player = Helper.GetPlayerFromSteamid64(steamid); - if (player == null || !player.IsValid || player.PlayerName == name) continue; - player.Rename(name); - } - }, TimerFlags.REPEAT); - CS2_SimpleAdmin.Instance.PlayersTimer = CS2_SimpleAdmin.Instance.AddTimer(61.0f, () => { #if DEBUG diff --git a/CS2-SimpleAdmin/Models/IpHistoryRow.cs b/CS2-SimpleAdmin/Models/IpHistoryRow.cs deleted file mode 100644 index 5c794a7..0000000 --- a/CS2-SimpleAdmin/Models/IpHistoryRow.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace CS2_SimpleAdmin.Models; - -public record IpHistoryRow -{ - public long Steamid { get; init; } - public string? Name { get; init; } - public uint Address { get; init; } - public DateTime Used_at { get; init; } -} diff --git a/CS2-SimpleAdmin/VERSION b/CS2-SimpleAdmin/VERSION index c7a73ab..e86c1d6 100644 --- a/CS2-SimpleAdmin/VERSION +++ b/CS2-SimpleAdmin/VERSION @@ -1 +1 @@ -1.8.2b \ No newline at end of file +1.8.1a \ No newline at end of file