Skip to content

Commit

Permalink
Patch v1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
K4ryuu committed Jul 2, 2024
1 parent 3dc88a2 commit 375cb9b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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
Expand Down
30 changes: 18 additions & 12 deletions src/KitsuneSteamRestrict.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -89,7 +92,7 @@ public sealed class DatabaseSettings
public class SteamRestrictPlugin : BasePlugin, IPluginConfig<PluginConfig>
{
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.";

Expand Down Expand Up @@ -231,35 +234,38 @@ 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}");
}

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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/Models/SteamService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -145,6 +146,7 @@ private void ParseSteamUserInfo(string json, SteamUserInfo userInfo)
if (player != null)
{
userInfo.IsPrivate = player["communityvisibilitystate"]?.ToObject<int?>() != 3;
userInfo.IsGameDetailsPrivate = player["gameextrainfo"] == null;
int? timeCreated = player["timecreated"]?.ToObject<int?>();
userInfo.SteamAccountAge = timeCreated.HasValue
? new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(timeCreated.Value)
Expand Down

0 comments on commit 375cb9b

Please sign in to comment.