diff --git a/CHANGELOG.md b/CHANGELOG.md index 3320a56c..04b5b844 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -74,6 +74,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Removed `Utils.GetPlayerIP()`. (@hakusaro) * Moved `Utils.Ban()` to `TSPlayer.Ban()`. (@hakusaro) * Moved `Utils.SendMultipleMatchError()` to `TSPlayer.SendMultipleMatchError`. (@hakusaro) +* Removed `Utils.GetPlayers()`. Iterate over the TSPlayers on the server and make your own list. ## TShock 4.3.25 * Fixed a critical exploit in the Terraria protocol that could cause massive unpreventable world corruption as well as a number of other problems. Thanks to @bartico6 for reporting. Fixed by the efforts of @QuiCM, @hakusaro, and tips in the right directioon from @bartico6. diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index edbdcd83..d7cdcf96 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -4820,8 +4820,26 @@ namespace TShockAPI } args.Player.SendSuccessMessage("Online Players ({0}/{1})", TShock.Players.Length, TShock.Config.MaxSlots); + + var players = new List(); + + foreach (TSPlayer ply in TShock.Players) + { + if (ply != null && ply.Active) + { + if (displayIdsRequested) + { + players.Add(String.Format("{0} (ID: {1}{2})", ply.Name, ply.Index, ply.Account != null ? ", ID: " + ply.Account.ID : "")); + } + else + { + players.Add(ply.Name); + } + } + } + PaginationTools.SendPage( - args.Player, pageNumber, PaginationTools.BuildLinesFromTerms(TShock.Utils.GetPlayers(displayIdsRequested)), + args.Player, pageNumber, PaginationTools.BuildLinesFromTerms(players), new PaginationTools.Settings { IncludeHeader = false, diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index b8f084bf..c6cfc7c4 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -69,33 +69,6 @@ namespace TShockAPI return mess.Split(':')[0]; } - /// - /// Returns a list of current players on the server - /// - /// bool includeIDs - whether or not the string of each player name should include ID data - /// List of strings with names - public List GetPlayers(bool includeIDs) - { - var players = new List(); - - foreach (TSPlayer ply in TShock.Players) - { - if (ply != null && ply.Active) - { - if (includeIDs) - { - players.Add(String.Format("{0} (IX: {1}{2})", ply.Name, ply.Index, ply.Account != null ? ", ID: " + ply.Account.ID : "")); - } - else - { - players.Add(ply.Name); - } - } - } - - return players; - } - /// /// It's a clamp function /// @@ -549,8 +522,18 @@ namespace TShockAPI continue; } + var players = new List(); + + foreach (TSPlayer ply in TShock.Players) + { + if (ply != null && ply.Active) + { + players.Add(ply.Name); + } + } + foo = foo.Replace("%map%", (TShock.Config.UseServerName ? TShock.Config.ServerName : Main.worldName)); - foo = foo.Replace("%players%", String.Join(",", GetPlayers(false))); + foo = foo.Replace("%players%", String.Join(",", players)); player.SendMessage(foo, lineColor); }