From a0e12c14402b57917b64bfa8021f107d18ee21ed Mon Sep 17 00:00:00 2001 From: sudokoko Date: Thu, 7 May 2026 09:21:49 -0400 Subject: [PATCH 1/2] feat: add config option for displaying online players on website --- .../Pages/LandingPage.cshtml | 17 ++++++++++------- .../WebsiteConfiguration.cs | 9 +++++---- .../Configuration/ServerConfiguration.cs | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/ProjectLighthouse.Servers.Website/Pages/LandingPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/LandingPage.cshtml index 1414c642e..49f969d42 100644 --- a/ProjectLighthouse.Servers.Website/Pages/LandingPage.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/LandingPage.cshtml @@ -47,15 +47,18 @@ } @{ - int i = 0; - foreach (UserEntity user in Model.PlayersOnline) + if (ServerConfiguration.Instance.WebsiteConfiguration.ShowOnlinePlayers) { - i++; - @await user.ToLink(Html, ViewData, language, timeZone, true) - @* whitespace has forced my hand *@ - if (i != Model.PlayersOnline.Count) + int i = 0; + foreach (UserEntity user in Model.PlayersOnline) { - , + i++; + @await user.ToLink(Html, ViewData, language, timeZone, true) + @* whitespace has forced my hand *@ + if (i != Model.PlayersOnline.Count) + { + , + } } } } diff --git a/ProjectLighthouse/Configuration/ConfigurationCategories/WebsiteConfiguration.cs b/ProjectLighthouse/Configuration/ConfigurationCategories/WebsiteConfiguration.cs index 39fe337a4..e210126c4 100644 --- a/ProjectLighthouse/Configuration/ConfigurationCategories/WebsiteConfiguration.cs +++ b/ProjectLighthouse/Configuration/ConfigurationCategories/WebsiteConfiguration.cs @@ -6,9 +6,10 @@ public class WebsiteConfiguration public bool ConvertAssetsOnStartup { get; set; } = true; - /* - * Decides whether or not to display the Lighthouse Pride logo - * during the month of June if enabled. - */ + /// + /// Displays the Lighthouse Pride logo during the month of June. + /// public bool PrideEventEnabled { get; set; } = true; + + public bool ShowOnlinePlayers { get; set; } = true; } \ No newline at end of file diff --git a/ProjectLighthouse/Configuration/ServerConfiguration.cs b/ProjectLighthouse/Configuration/ServerConfiguration.cs index d145495c6..1bb7cba27 100644 --- a/ProjectLighthouse/Configuration/ServerConfiguration.cs +++ b/ProjectLighthouse/Configuration/ServerConfiguration.cs @@ -11,7 +11,7 @@ public class ServerConfiguration : ConfigurationBase // This is so Lighthouse can properly identify outdated configurations and update them with newer settings accordingly. // If you are modifying anything here, this value MUST be incremented. // Thanks for listening~ - public override int ConfigVersion { get; set; } = 31; + public override int ConfigVersion { get; set; } = 32; public override string ConfigName { get; set; } = "lighthouse.yml"; public string WebsiteListenUrl { get; set; } = "http://localhost:10060"; From 5d1ff9bb35f4afbe8f1f7d13628156ea5a30800b Mon Sep 17 00:00:00 2001 From: sudokoko Date: Thu, 7 May 2026 09:40:02 -0400 Subject: [PATCH 2/2] fix: return NotFound on playerlist endpoint if config option is disabled --- .../Controllers/StatisticsEndpoints.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ProjectLighthouse.Servers.API/Controllers/StatisticsEndpoints.cs b/ProjectLighthouse.Servers.API/Controllers/StatisticsEndpoints.cs index 76310aecc..5439907f0 100644 --- a/ProjectLighthouse.Servers.API/Controllers/StatisticsEndpoints.cs +++ b/ProjectLighthouse.Servers.API/Controllers/StatisticsEndpoints.cs @@ -1,3 +1,4 @@ +using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Filter; using LBPUnion.ProjectLighthouse.Filter.Filters; @@ -113,13 +114,15 @@ public async Task GetPlayerCountsByPlatform() } /// - /// Gets a list of online players + /// Gets a list of online players /// /// An instance of PlayerListResponse [HttpGet("players")] [ProducesResponseType(typeof(PlayerListResponse), StatusCodes.Status200OK)] public async Task GetPlayerList() { + if (!ServerConfiguration.Instance.WebsiteConfiguration.ShowOnlinePlayers) return this.NotFound(); + List players = await this.database.LastContacts.Where(l => TimeHelper.Timestamp - l.Timestamp < 300) .Select(l => new PlayerListObject {