From 375cb9b01c35b96dc81d665832b417c3a941d3d9 Mon Sep 17 00:00:00 2001 From: K4ryuu <104531589+K4ryuu@users.noreply.github.com> Date: Tue, 2 Jul 2024 16:27:39 +0200 Subject: [PATCH] Patch v1.4.1 --- CHANGELOG | 5 +++++ src/KitsuneSteamRestrict.cs | 30 ++++++++++++++++++------------ src/Models/SteamService.cs | 2 ++ 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 7c56aa6..687f71d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +-- 2024. 07. 02 - v1.4.1 + +- feat: Added option to change the warning print interval +- feat: Added log and check for game details privated + -- 2024. 07. 02 - v1.4.0 - feat: Added option to allow private profiles join for given seconds to warn them about the issue diff --git a/src/KitsuneSteamRestrict.cs b/src/KitsuneSteamRestrict.cs index 1bf275f..2759430 100644 --- a/src/KitsuneSteamRestrict.cs +++ b/src/KitsuneSteamRestrict.cs @@ -49,7 +49,10 @@ public class PluginConfig : BasePluginConfig public bool BlockGameBanned { get; set; } = false; [JsonPropertyName("PrivateProfileWarningTime")] - public int PrivateProfileWarningTime { get; set; } = 5; + public int PrivateProfileWarningTime { get; set; } = 20; + + [JsonPropertyName("PrivateProfileWarningPrintSeconds")] + public int PrivateProfileWarningPrintSeconds { get; set; } = 3; [JsonPropertyName("DatabaseSettings")] public DatabaseSettings DatabaseSettings { get; set; } = new DatabaseSettings(); @@ -89,7 +92,7 @@ public sealed class DatabaseSettings public class SteamRestrictPlugin : BasePlugin, IPluginConfig { public override string ModuleName => "Steam Restrict"; - public override string ModuleVersion => "1.4.0"; + public override string ModuleVersion => "1.4.1"; public override string ModuleAuthor => "K4ryuu, Cruze @ KitsuneLab"; public override string ModuleDescription => "Restrict certain players from connecting to your server."; @@ -231,6 +234,7 @@ private void CheckUserViolations(nint handle, ulong authorizedSteamID) Logger.LogInformation($"Steam Account Creation Date: N/A"); //Logger.LogInformation($"HasPrime: {userInfo.HasPrime}"); Removed due to people bought prime after CS2 cannot be detected sadly (or atleast not yet) Logger.LogInformation($"HasPrivateProfile: {userInfo.IsPrivate}"); + Logger.LogInformation($"HasPrivateGameDetails: {userInfo.IsGameDetailsPrivate}"); Logger.LogInformation($"IsTradeBanned: {userInfo.IsTradeBanned}"); Logger.LogInformation($"IsGameBanned: {userInfo.IsGameBanned}"); Logger.LogInformation($"IsInSteamGroup: {userInfo.IsInSteamGroup}"); @@ -238,28 +242,30 @@ private void CheckUserViolations(nint handle, ulong authorizedSteamID) if (IsRestrictionViolated(player, userInfo)) { - if (Config.PrivateProfileWarningTime > 0 && userInfo.IsPrivate) + if (Config.PrivateProfileWarningTime > 0 && (userInfo.IsPrivate || userInfo.IsGameDetailsPrivate)) { g_iWarnTime[player.Slot] = Config.PrivateProfileWarningTime; int playerSlot = player.Slot; - g_hTimer[playerSlot] = AddTimer(1, () => + AddTimer(Config.PrivateProfileWarningTime, () => + { + if (player?.IsValid == true) + Server.ExecuteCommand($"kickid {player.UserId} \"You have been kicked for not meeting the minimum requirements.\""); + }); + + g_hTimer[playerSlot] = AddTimer(Config.PrivateProfileWarningPrintSeconds, () => { if (player?.IsValid == true) { player.PrintToChat($" {ChatColors.Silver}[ {ChatColors.Lime}SteamRestrict {ChatColors.Silver}] {ChatColors.LightRed}Your Steam profile or Game details are private. You will be kicked in {g_iWarnTime[playerSlot]} seconds."); } - - g_iWarnTime[playerSlot]--; - - if (g_iWarnTime[playerSlot] <= 0) + else { - if (player?.IsValid == true) - Server.ExecuteCommand($"kickid {player.UserId} \"You have been kicked for not meeting the minimum requirements.\""); - g_hTimer[playerSlot]?.Kill(); g_hTimer[playerSlot] = null; } + + g_iWarnTime[playerSlot] -= Config.PrivateProfileWarningPrintSeconds; }, TimerFlags.REPEAT); } else @@ -300,7 +306,7 @@ private bool IsRestrictionViolated(CCSPlayerController player, SteamUserInfo use if (!(playerBypassConfig?.BypassMinimumSteamAccountAge ?? false) && Config.MinimumSteamAccountAgeInDays != -1 && (DateTime.Now - userInfo.SteamAccountAge).TotalDays < Config.MinimumSteamAccountAgeInDays) return true; - if (Config.BlockPrivateProfile && !(playerBypassConfig?.BypassPrivateProfile ?? false) && userInfo.IsPrivate) + if (Config.BlockPrivateProfile && !(playerBypassConfig?.BypassPrivateProfile ?? false) && (userInfo.IsPrivate || userInfo.IsGameDetailsPrivate)) return true; if (Config.BlockTradeBanned && !(playerBypassConfig?.BypassTradeBanned ?? false) && userInfo.IsTradeBanned) diff --git a/src/Models/SteamService.cs b/src/Models/SteamService.cs index f44214a..0d2bc8d 100644 --- a/src/Models/SteamService.cs +++ b/src/Models/SteamService.cs @@ -10,6 +10,7 @@ public class SteamUserInfo public int CS2Level { get; set; } public int CS2Playtime { get; set; } public bool IsPrivate { get; set; } + public bool IsGameDetailsPrivate { get; set; } public bool HasPrime { get; set; } public bool IsTradeBanned { get; set; } public bool IsVACBanned { get; set; } @@ -145,6 +146,7 @@ private void ParseSteamUserInfo(string json, SteamUserInfo userInfo) if (player != null) { userInfo.IsPrivate = player["communityvisibilitystate"]?.ToObject() != 3; + userInfo.IsGameDetailsPrivate = player["gameextrainfo"] == null; int? timeCreated = player["timecreated"]?.ToObject(); userInfo.SteamAccountAge = timeCreated.HasValue ? new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(timeCreated.Value)