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 { 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";