diff --git a/Serein/WPF/Serein-WPF.csproj b/Serein/WPF/Serein-WPF.csproj index 4bfd583d..4def6a2f 100644 --- a/Serein/WPF/Serein-WPF.csproj +++ b/Serein/WPF/Serein-WPF.csproj @@ -1,7 +1,7 @@ - WinExe + Exe net6.0-windows true false diff --git a/Serein/WPF/Windows/Pages/Server/PlayerList.xaml.cs b/Serein/WPF/Windows/Pages/Server/PlayerList.xaml.cs index 5dc12953..837aa557 100644 --- a/Serein/WPF/Windows/Pages/Server/PlayerList.xaml.cs +++ b/Serein/WPF/Windows/Pages/Server/PlayerList.xaml.cs @@ -40,39 +40,8 @@ public PlayerList() { while (true) - { - string? PlayerListItems = null; - PlayerListData = Motd.PlayerListData; - try - { - PlayerListItems = PlayerListData["sample"].ToString(); - } - catch - { - - } - items = new List(); - if (ServerManager.Status) - { - if (!string.IsNullOrEmpty(PlayerListItems)) - { - for (int a = 0; a < PlayerListData["sample"].Count(); a++) - { - string? Username = PlayerListData["sample"][a]["name"].ToString(); - string? UUID = PlayerListData["sample"][a]["id"].ToString(); - items.Add(new Player() { Username = Username, UUID = UUID }); - } - } - } - else - { - - } - - Dispatcher.Invoke(() => - { - PlayerListView.ItemsSource = items; - }); + { + refresh(); Thread.Sleep(500); } }); @@ -83,7 +52,6 @@ private void refresh() { string? PlayerListItems = null; PlayerListData = Motd.PlayerListData; - Console.WriteLine(PlayerListData); try { PlayerListItems = PlayerListData["sample"].ToString(); @@ -93,19 +61,28 @@ private void refresh() } items = new List(); - if (!string.IsNullOrEmpty(PlayerListItems)) + if (ServerManager.Status) { - - for (int a = 0; a < PlayerListData["sample"].Count(); a++) + if (!string.IsNullOrEmpty(PlayerListItems)) { - string? Username = PlayerListData["sample"][a]["name"].ToString(); - string? UUID = PlayerListData["sample"][a]["id"].ToString(); - items.Add(new Player() { Username = Username, UUID = UUID }); + for (int a = 0; a < PlayerListData["sample"].Count(); a++) + { + string? Username = PlayerListData["sample"][a]["name"].ToString(); + string? UUID = PlayerListData["sample"][a]["id"].ToString(); + string? IP = null; + items.Add(new Player() { Username = Username, UUID = UUID, IP = IP }); + } } - + } + else + { } - PlayerListView.ItemsSource = items; + + Dispatcher.Invoke(() => + { + PlayerListView.ItemsSource = items; + }); } private void ListView_ContextMenuOpening(object sender, ContextMenuEventArgs e) { @@ -283,11 +260,12 @@ private void PlayerListView_MouseDown(object sender, MouseButtonEventArgs e) } public class Player { - public string Username { get; set; } - public string UUID { get; set; } + public string? Username { get; set; } + public string? UUID { get; set; } + public string? IP { get; set; } public override string ToString() { - return this.Username + " (" + this.UUID + ")"; + return this.Username + " (" + this.UUID + ") IP:" + this.IP; } } }