From 3b8797c52c36af7828cebaae5e94753f4bf33db9 Mon Sep 17 00:00:00 2001 From: INZI Date: Sun, 4 Feb 2024 10:17:03 +0100 Subject: [PATCH 01/16] [Exiled::API] Added AccountAge to Features.Player --- Exiled.API/Exiled.API.csproj | 2 ++ Exiled.API/Features/Player.cs | 52 +++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/Exiled.API/Exiled.API.csproj b/Exiled.API/Exiled.API.csproj index 19a95ee8e6..094d936382 100644 --- a/Exiled.API/Exiled.API.csproj +++ b/Exiled.API/Exiled.API.csproj @@ -20,6 +20,7 @@ + @@ -37,6 +38,7 @@ + diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 3c180239c5..6f0542a549 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -10,6 +10,7 @@ namespace Exiled.API.Features using System; using System.Collections.Generic; using System.Linq; + using System.Net.Http; using System.Reflection; using System.Runtime.CompilerServices; @@ -30,6 +31,7 @@ namespace Exiled.API.Features using Footprinting; using global::Scp914; using Hints; + using HtmlAgilityPack; using Interactables.Interobjects; using InventorySystem; using InventorySystem.Disarming; @@ -1094,6 +1096,56 @@ public bool BadgeHidden /// public int Ping => LiteNetLib4MirrorServer.GetPing(Connection.connectionId); + /// + /// Gets the Steam account age of the player in days. + /// + /// + /// This property retrieves the Steam account age by making a synchronous HTTP request to steamid.io. + /// It is recommended to use the asynchronous method when possible. + /// + /// The Steam account age of the player in days. Returns -1 if an error occurs during retrieval. + public int AccountAge + { + get + { + try + { + string userId = UserId; + int index = userId.IndexOf('@'); + + if (index != -1) + userId = userId.Substring(0, index); + + string url = $"https://steamid.io/lookup/{userId}"; + + using (HttpClient httpClient = new HttpClient()) + { + HttpResponseMessage response = httpClient.GetAsync(url).GetAwaiter().GetResult(); + response.EnsureSuccessStatusCode(); + + string html = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); + + HtmlDocument doc = new HtmlDocument(); + doc.LoadHtml(html); + + HtmlNode infoNode = doc.DocumentNode.SelectSingleNode("//*[@id=\"content\"]/dl/dd[6]"); + string infoText = infoNode?.InnerText; + + DateTime parsedDate = DateTime.Parse(infoText); + DateTime now = DateTime.Now; + + TimeSpan ts = now.Subtract(parsedDate); + return (int)ts.TotalDays; + } + } + catch (Exception ex) + { + Log.Error($"Error retrieving Steam account age for player {Nickname}: {ex.Message}"); + return -1; + } + } + } + /// /// Gets the player's items. /// From 7739c0151a11d140f14842f2a205bcbab555646b Mon Sep 17 00:00:00 2001 From: INZI Date: Sun, 4 Feb 2024 10:34:56 +0100 Subject: [PATCH 02/16] [Exiled::API] Additions to Features.Player --- Exiled.API/Features/Player.cs | 65 ++++++++--------------------------- 1 file changed, 15 insertions(+), 50 deletions(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 6f0542a549..922d81b17a 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -49,6 +49,7 @@ namespace Exiled.API.Features using NorthwoodLib; using PlayerRoles; using PlayerRoles.FirstPersonControl; + using PlayerRoles.PlayableScps.Scp096; using PlayerRoles.RoleAssign; using PlayerRoles.Spectating; using PlayerRoles.Voice; @@ -96,6 +97,10 @@ public class Player : GameEntity private ReferenceHub referenceHub; private CustomHealthStat healthStat; private Role role; + private Roles.Scp096Role scp096Role; + private Roles.Scp173Role scp173Role; + + /// /// Initializes a new instance of the class. @@ -1096,56 +1101,6 @@ public bool BadgeHidden /// public int Ping => LiteNetLib4MirrorServer.GetPing(Connection.connectionId); - /// - /// Gets the Steam account age of the player in days. - /// - /// - /// This property retrieves the Steam account age by making a synchronous HTTP request to steamid.io. - /// It is recommended to use the asynchronous method when possible. - /// - /// The Steam account age of the player in days. Returns -1 if an error occurs during retrieval. - public int AccountAge - { - get - { - try - { - string userId = UserId; - int index = userId.IndexOf('@'); - - if (index != -1) - userId = userId.Substring(0, index); - - string url = $"https://steamid.io/lookup/{userId}"; - - using (HttpClient httpClient = new HttpClient()) - { - HttpResponseMessage response = httpClient.GetAsync(url).GetAwaiter().GetResult(); - response.EnsureSuccessStatusCode(); - - string html = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); - - HtmlDocument doc = new HtmlDocument(); - doc.LoadHtml(html); - - HtmlNode infoNode = doc.DocumentNode.SelectSingleNode("//*[@id=\"content\"]/dl/dd[6]"); - string infoText = infoNode?.InnerText; - - DateTime parsedDate = DateTime.Parse(infoText); - DateTime now = DateTime.Now; - - TimeSpan ts = now.Subtract(parsedDate); - return (int)ts.TotalDays; - } - } - catch (Exception ex) - { - Log.Error($"Error retrieving Steam account age for player {Nickname}: {ex.Message}"); - return -1; - } - } - } - /// /// Gets the player's items. /// @@ -1161,6 +1116,16 @@ public int AccountAge /// public bool IsInventoryFull => Items.Count >= Inventory.MaxSlots; + /// + /// Gets a value indicating whether or not the is target of SCP 096. + /// + public bool IsScp096Target => Player.Get(RoleTypeId.Scp096).Any(player => scp096Role.Targets.Contains(player)); + + /// + /// Gets a value indicating whether or not the is observing SCP 173. + /// + public bool IsScp173Observer => Player.Get(RoleTypeId.Scp173).Any(player => scp173Role.ObservingPlayers.Contains(player)); + /// /// Gets a value indicating whether or not the player has agreed to microphone recording. /// From 97aa75010d056e48fefe98c3cd096ae81bf9429a Mon Sep 17 00:00:00 2001 From: "Dr. Inzi" <158808246+DrInzi@users.noreply.github.com> Date: Sun, 4 Feb 2024 10:36:56 +0100 Subject: [PATCH 03/16] Update Exiled.API.csproj --- Exiled.API/Exiled.API.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/Exiled.API/Exiled.API.csproj b/Exiled.API/Exiled.API.csproj index 094d936382..7e224015e0 100644 --- a/Exiled.API/Exiled.API.csproj +++ b/Exiled.API/Exiled.API.csproj @@ -20,7 +20,6 @@ - From f3862ab7fbd9306f854f9133b51cefb40bd8c213 Mon Sep 17 00:00:00 2001 From: "Dr. Inzi" <158808246+DrInzi@users.noreply.github.com> Date: Sun, 4 Feb 2024 10:37:29 +0100 Subject: [PATCH 04/16] Update Player.cs --- Exiled.API/Features/Player.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 922d81b17a..e785ba82ea 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -10,7 +10,6 @@ namespace Exiled.API.Features using System; using System.Collections.Generic; using System.Linq; - using System.Net.Http; using System.Reflection; using System.Runtime.CompilerServices; @@ -31,7 +30,6 @@ namespace Exiled.API.Features using Footprinting; using global::Scp914; using Hints; - using HtmlAgilityPack; using Interactables.Interobjects; using InventorySystem; using InventorySystem.Disarming; From 4293fe405317a12b6f94beb25f63ded4ea189798 Mon Sep 17 00:00:00 2001 From: "Dr. Inzi" <158808246+DrInzi@users.noreply.github.com> Date: Sun, 4 Feb 2024 10:37:57 +0100 Subject: [PATCH 05/16] Update Exiled.API.csproj --- Exiled.API/Exiled.API.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/Exiled.API/Exiled.API.csproj b/Exiled.API/Exiled.API.csproj index 7e224015e0..19a95ee8e6 100644 --- a/Exiled.API/Exiled.API.csproj +++ b/Exiled.API/Exiled.API.csproj @@ -37,7 +37,6 @@ - From 131544a21fb526cf0c2dc34d882f297a05835f99 Mon Sep 17 00:00:00 2001 From: "Dr. Inzi" <158808246+DrInzi@users.noreply.github.com> Date: Sun, 4 Feb 2024 10:41:01 +0100 Subject: [PATCH 06/16] Update Player.cs --- Exiled.API/Features/Player.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index e785ba82ea..62d1b279ee 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -1117,12 +1117,12 @@ public bool BadgeHidden /// /// Gets a value indicating whether or not the is target of SCP 096. /// - public bool IsScp096Target => Player.Get(RoleTypeId.Scp096).Any(player => scp096Role.Targets.Contains(player)); + public bool IsScp096Target => Player.List.Any(player => scp096Role.Targets.Contains(player)); /// /// Gets a value indicating whether or not the is observing SCP 173. /// - public bool IsScp173Observer => Player.Get(RoleTypeId.Scp173).Any(player => scp173Role.ObservingPlayers.Contains(player)); + public bool IsScp173Observer => Player.List.Any(player => scp173Role.ObservingPlayers.Contains(player)); /// /// Gets a value indicating whether or not the player has agreed to microphone recording. From 2455aefe6c5efaf014573ab6001566989fcb9d1a Mon Sep 17 00:00:00 2001 From: "Dr. Inzi" <158808246+DrInzi@users.noreply.github.com> Date: Sun, 4 Feb 2024 11:03:43 +0100 Subject: [PATCH 07/16] Update Player.cs (reviews with yamato baguette) --- Exiled.API/Features/Player.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 62d1b279ee..e869338324 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -98,8 +98,6 @@ public class Player : GameEntity private Roles.Scp096Role scp096Role; private Roles.Scp173Role scp173Role; - - /// /// Initializes a new instance of the class. /// @@ -1115,10 +1113,14 @@ public bool BadgeHidden public bool IsInventoryFull => Items.Count >= Inventory.MaxSlots; /// - /// Gets a value indicating whether or not the is target of SCP 096. + /// Gets a value indicating whether the player is a target of SCP-096. /// - public bool IsScp096Target => Player.List.Any(player => scp096Role.Targets.Contains(player)); - + /// + /// This property checks if the player is present in the list of targets maintained by SCP-096. + /// + /// True if the player is a target of SCP-096; otherwise, false. + public bool IsScp096Target => Player.List.Any(x => x.Role is Scp096Role scp096Role && scp096Role.Targets.Contains(x)); + /// /// Gets a value indicating whether or not the is observing SCP 173. /// From bb555692f0f465e86cd765a1569055bcbbbcacbe Mon Sep 17 00:00:00 2001 From: "Dr. Inzi" <158808246+DrInzi@users.noreply.github.com> Date: Sun, 4 Feb 2024 11:06:26 +0100 Subject: [PATCH 08/16] Update Player.cs --- Exiled.API/Features/Player.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index e869338324..8f804552b3 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -1121,10 +1121,14 @@ public bool BadgeHidden /// True if the player is a target of SCP-096; otherwise, false. public bool IsScp096Target => Player.List.Any(x => x.Role is Scp096Role scp096Role && scp096Role.Targets.Contains(x)); - /// - /// Gets a value indicating whether or not the is observing SCP 173. + // + /// Gets a value indicating whether the player is a target of SCP-173. /// - public bool IsScp173Observer => Player.List.Any(player => scp173Role.ObservingPlayers.Contains(player)); + /// + /// This property checks if the player is present in the list of observers maintained by SCP-173. + /// + /// True if the player is a observer of SCP-173; otherwise, false. + public bool IsScp173Observer => Player.List.Any(x => x.Role is Roles.Scp173Role scp173Role && scp173Role.ObservingPlayers.Contains(x)); /// /// Gets a value indicating whether or not the player has agreed to microphone recording. From 78a84bce764587aad6c347229da14712e5e16189 Mon Sep 17 00:00:00 2001 From: "Dr. Inzi" <158808246+DrInzi@users.noreply.github.com> Date: Sun, 4 Feb 2024 11:06:57 +0100 Subject: [PATCH 09/16] Update Player.cs --- Exiled.API/Features/Player.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 8f804552b3..dce803cc22 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -95,9 +95,7 @@ public class Player : GameEntity private ReferenceHub referenceHub; private CustomHealthStat healthStat; private Role role; - private Roles.Scp096Role scp096Role; - private Roles.Scp173Role scp173Role; - + /// /// Initializes a new instance of the class. /// From 419b9ea7795dce8b6cc9af9b5618205d519086b7 Mon Sep 17 00:00:00 2001 From: "Dr. Inzi" <158808246+DrInzi@users.noreply.github.com> Date: Sun, 4 Feb 2024 11:08:18 +0100 Subject: [PATCH 10/16] Update Player.cs --- Exiled.API/Features/Player.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index dce803cc22..771bd60533 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -95,7 +95,7 @@ public class Player : GameEntity private ReferenceHub referenceHub; private CustomHealthStat healthStat; private Role role; - + /// /// Initializes a new instance of the class. /// From fd0d572d8af79c343acfb52f39831aef26640d82 Mon Sep 17 00:00:00 2001 From: "Dr. Inzi" <158808246+DrInzi@users.noreply.github.com> Date: Sun, 4 Feb 2024 11:13:37 +0100 Subject: [PATCH 11/16] Update Player.cs --- Exiled.API/Features/Player.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 771bd60533..1a0c2b1fcc 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -1117,7 +1117,7 @@ public bool BadgeHidden /// This property checks if the player is present in the list of targets maintained by SCP-096. /// /// True if the player is a target of SCP-096; otherwise, false. - public bool IsScp096Target => Player.List.Any(x => x.Role is Scp096Role scp096Role && scp096Role.Targets.Contains(x)); + public bool IsScp096Target => Player.List.Any(x => x.Role is Roles.Scp096Role scp096Role && scp096Role.Targets.Contains(x)); // /// Gets a value indicating whether the player is a target of SCP-173. From 76e209a6df75feef5e325f851ea489f5c53aeacc Mon Sep 17 00:00:00 2001 From: "Dr. Inzi" <158808246+DrInzi@users.noreply.github.com> Date: Sun, 4 Feb 2024 11:14:38 +0100 Subject: [PATCH 12/16] Update Player.cs --- Exiled.API/Features/Player.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 1a0c2b1fcc..afbe25d3e3 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -1120,7 +1120,7 @@ public bool BadgeHidden public bool IsScp096Target => Player.List.Any(x => x.Role is Roles.Scp096Role scp096Role && scp096Role.Targets.Contains(x)); // - /// Gets a value indicating whether the player is a target of SCP-173. + /// Gets a value indicating whether the player is a observer of SCP-173. /// /// /// This property checks if the player is present in the list of observers maintained by SCP-173. From 7e166fa5e920ff85acc5c6e90a65a280f8eb9280 Mon Sep 17 00:00:00 2001 From: "Dr. Inzi" <158808246+DrInzi@users.noreply.github.com> Date: Sun, 4 Feb 2024 11:17:30 +0100 Subject: [PATCH 13/16] Update Player.cs --- Exiled.API/Features/Player.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index afbe25d3e3..90a73d1f1b 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -1120,12 +1120,12 @@ public bool BadgeHidden public bool IsScp096Target => Player.List.Any(x => x.Role is Roles.Scp096Role scp096Role && scp096Role.Targets.Contains(x)); // - /// Gets a value indicating whether the player is a observer of SCP-173. + /// Gets a value indicating whether the player is an observer of SCP-173. /// /// /// This property checks if the player is present in the list of observers maintained by SCP-173. /// - /// True if the player is a observer of SCP-173; otherwise, false. + /// True if the player is an observer of SCP-173; otherwise, false. public bool IsScp173Observer => Player.List.Any(x => x.Role is Roles.Scp173Role scp173Role && scp173Role.ObservingPlayers.Contains(x)); /// From 1d11ff6200282e733049fd356335606cb3ac3db6 Mon Sep 17 00:00:00 2001 From: "Dr. Inzi" <158808246+DrInzi@users.noreply.github.com> Date: Sun, 4 Feb 2024 11:18:34 +0100 Subject: [PATCH 14/16] Update Player.cs --- Exiled.API/Features/Player.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 90a73d1f1b..1ceada0916 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -47,7 +47,6 @@ namespace Exiled.API.Features using NorthwoodLib; using PlayerRoles; using PlayerRoles.FirstPersonControl; - using PlayerRoles.PlayableScps.Scp096; using PlayerRoles.RoleAssign; using PlayerRoles.Spectating; using PlayerRoles.Voice; From 6e319cef48168d464bdacd14d3afb2c39df1ffc7 Mon Sep 17 00:00:00 2001 From: "Dr. Inzi" <158808246+DrInzi@users.noreply.github.com> Date: Sun, 4 Feb 2024 11:31:40 +0100 Subject: [PATCH 15/16] Update Player.cs --- Exiled.API/Features/Player.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 1ceada0916..d4d42bfeb1 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -1118,7 +1118,7 @@ public bool BadgeHidden /// True if the player is a target of SCP-096; otherwise, false. public bool IsScp096Target => Player.List.Any(x => x.Role is Roles.Scp096Role scp096Role && scp096Role.Targets.Contains(x)); - // + /// /// Gets a value indicating whether the player is an observer of SCP-173. /// /// From 243e3d0049855668d380ee6c388faa4cce281ab1 Mon Sep 17 00:00:00 2001 From: INZI Date: Sun, 4 Feb 2024 11:41:57 +0100 Subject: [PATCH 16/16] Merge branch 'IsScp096Target-IsScp173Observer' of https://github.com/DrInzi/EXILED into IsScp096Target-IsScp173Observer --- Exiled.API/Exiled.API.csproj | 2 -- Exiled.API/Features/Player.cs | 23 ++++++++++++----------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Exiled.API/Exiled.API.csproj b/Exiled.API/Exiled.API.csproj index 094d936382..19a95ee8e6 100644 --- a/Exiled.API/Exiled.API.csproj +++ b/Exiled.API/Exiled.API.csproj @@ -20,7 +20,6 @@ - @@ -38,7 +37,6 @@ - diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 922d81b17a..d2dd65a465 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -10,7 +10,6 @@ namespace Exiled.API.Features using System; using System.Collections.Generic; using System.Linq; - using System.Net.Http; using System.Reflection; using System.Runtime.CompilerServices; @@ -31,7 +30,6 @@ namespace Exiled.API.Features using Footprinting; using global::Scp914; using Hints; - using HtmlAgilityPack; using Interactables.Interobjects; using InventorySystem; using InventorySystem.Disarming; @@ -49,7 +47,6 @@ namespace Exiled.API.Features using NorthwoodLib; using PlayerRoles; using PlayerRoles.FirstPersonControl; - using PlayerRoles.PlayableScps.Scp096; using PlayerRoles.RoleAssign; using PlayerRoles.Spectating; using PlayerRoles.Voice; @@ -97,10 +94,6 @@ public class Player : GameEntity private ReferenceHub referenceHub; private CustomHealthStat healthStat; private Role role; - private Roles.Scp096Role scp096Role; - private Roles.Scp173Role scp173Role; - - /// /// Initializes a new instance of the class. @@ -1117,14 +1110,22 @@ public bool BadgeHidden public bool IsInventoryFull => Items.Count >= Inventory.MaxSlots; /// - /// Gets a value indicating whether or not the is target of SCP 096. + /// Gets a value indicating whether the player is a target of SCP-096. /// - public bool IsScp096Target => Player.Get(RoleTypeId.Scp096).Any(player => scp096Role.Targets.Contains(player)); + /// + /// This property checks if the player is present in the list of targets maintained by SCP-096. + /// + /// True if the player is a target of SCP-096; otherwise, false. + public bool IsScp096Target => Player.List.Any(x => x.Role is Roles.Scp096Role scp096Role && scp096Role.Targets.Contains(x)); /// - /// Gets a value indicating whether or not the is observing SCP 173. + /// Gets a value indicating whether the player is an observer of SCP-173. /// - public bool IsScp173Observer => Player.Get(RoleTypeId.Scp173).Any(player => scp173Role.ObservingPlayers.Contains(player)); + /// + /// This property checks if the player is present in the list of observers maintained by SCP-173. + /// + /// True if the player is an observer of SCP-173; otherwise, false. + public bool IsScp173Observer => Player.List.Any(x => x.Role is Roles.Scp173Role scp173Role && scp173Role.ObservingPlayers.Contains(x)); /// /// Gets a value indicating whether or not the player has agreed to microphone recording.