diff --git a/Directory.Packages.props b/Directory.Packages.props index 89a44ba7..be585a5a 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -3,6 +3,7 @@ true + diff --git a/src/Application/CTF.Application.csproj b/src/Application/CTF.Application.csproj index 2b91f1a9..aa30e1b6 100644 --- a/src/Application/CTF.Application.csproj +++ b/src/Application/CTF.Application.csproj @@ -5,6 +5,7 @@ + diff --git a/src/Application/Players/GeneralCommands/AdminCommands.cs b/src/Application/Players/GeneralCommands/AdminCommands.cs index d97035f5..d8d22e7b 100644 --- a/src/Application/Players/GeneralCommands/AdminCommands.cs +++ b/src/Application/Players/GeneralCommands/AdminCommands.cs @@ -106,20 +106,40 @@ public void ShowBannedIPs(Player currentPlayer) if (currentPlayer.HasLowerRoleThan(RoleId.Admin)) return; - var path = Path.Combine(Directory.GetCurrentDirectory(), "samp.ban"); - var bannedIPs = File.ReadAllLines(path); - if (bannedIPs.Length == 0) + var path = Path.Combine(Directory.GetCurrentDirectory(), "bans.json"); + var content = File.ReadAllText(path); + var options = new JsonSerializerOptions + { + PropertyNameCaseInsensitive = true + }; + var bannedPlayers = JsonSerializer.Deserialize(content, options); + if (bannedPlayers.Length == 0) { currentPlayer.SendClientMessage(Color.Red, Messages.NoMatchFound); return; } - var dialog = new ListDialog(caption: $"Banned IPs: {bannedIPs.Length}", "Close"); - foreach (string bannedIP in bannedIPs) + var dialog = new ListDialog(caption: $"Banned Players: {bannedPlayers.Length}", "Close"); + foreach (BannedPlayer bannedPlayer in bannedPlayers) { - dialog.Add(bannedIP); + dialog.Add(bannedPlayer.ToString()); } dialogService.ShowAsync(currentPlayer, dialog); } + + private class BannedPlayer + { + public string Address { get; set; } = string.Empty; + public string Player { get; set; } = string.Empty; + public string Reason { get; set; } = string.Empty; + public string Time { get; set; } = "2023-12-07T16:05:21-0500"; + public override string ToString() + { + var dt = DateTimeOffset.Parse(Time).DateTime; + var date = dt.ToString("yyyy/MM/dd"); + var time = dt.ToString("HH:mm:ss"); + return $"{Address} [{date} | {time}] {Player} - {Reason}"; + } + } } diff --git a/src/Application/Usings.cs b/src/Application/Usings.cs index 812f7993..a8705545 100644 --- a/src/Application/Usings.cs +++ b/src/Application/Usings.cs @@ -1,4 +1,5 @@ -global using System.Collections; +global using System.Text.Json; +global using System.Collections; global using System.Globalization; global using System.Reflection; global using System.Text.RegularExpressions;