Remove Utils.GetPlayers().

This is a public method that only has two uses in TShock and both of
them are listing players to a player. A foreach isn't rocket science and
this method was originally created just because there was no good object
to iterate on (e.g., a TSPlayer array).
This commit is contained in:
Lucas Nicodemus 2017-12-29 08:26:51 -07:00
parent 48393d60c7
commit f06d1fd238
3 changed files with 31 additions and 29 deletions

View file

@ -69,33 +69,6 @@ namespace TShockAPI
return mess.Split(':')[0];
}
/// <summary>
/// Returns a list of current players on the server
/// </summary>
/// <param name="includeIDs">bool includeIDs - whether or not the string of each player name should include ID data</param>
/// <returns>List of strings with names</returns>
public List<string> GetPlayers(bool includeIDs)
{
var players = new List<string>();
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;
}
/// <summary>
/// It's a clamp function
/// </summary>
@ -549,8 +522,18 @@ namespace TShockAPI
continue;
}
var players = new List<string>();
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);
}