Add TSPlayer.ActivePlayers

This commit is contained in:
Lucas Nicodemus 2017-12-31 01:13:03 -07:00
parent 4eebaf6c44
commit 17cfdc3a16
2 changed files with 13 additions and 1 deletions

View file

@ -68,7 +68,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
* Removed _all obsolete methods in TShock marked obsolete prior to this version (all of them)_ (@hakusaro).
* Removed broken noclip detection and attempted prevention. TShock wasn't doing a good job at stopping noclip. It's always worse to claim that you do something that you can't/don't do, so removing this is better than keeping broken detection in. (@hakusaro)
* Replaced `Utils.FindPlayer` with `TSPlayer.FindByNameOrID` to more appropriately be object orientated. (@hakusaro)
* Removed `Utils.ActivePlayers()` -- use `TShock.Players.Length` instead. (@hakusaro)
* Removed `Utils.ActivePlayers()` -- use `TSPlayer.ActivePlayers.Count` instead. (@hakusaro)
* Moved `Utils.Kick()` to `TSPlayer` since its first argument was a `TSPlayer` object. (@hakusaro)
* Removed `Utils.ForceKick()`. (@hakusaro)
* Removed `Utils.GetPlayerIP()`. (@hakusaro)

View file

@ -74,6 +74,18 @@ namespace TShockAPI
/// </summary>
public static readonly TSPlayer All = new TSPlayer("All");
/// <summary>
/// Gets the number of active players on the server.
/// </summary>
/// <returns>The number of active players on the server.</returns>
public static ICollection<TSPlayer> ActivePlayers
{
get
{
return TShock.Players.Where(p => null != p && p.TPlayer.active) as ICollection<TSPlayer>;
}
}
/// <summary>
/// Finds a TSPlayer based on name or ID
/// </summary>