Rename Utils.ActivePlayers to something better.

Issues related to ICollections being null led to reverting migrating
this to TSPlayer until a better solution is uncovered.
This commit is contained in:
Lucas Nicodemus 2017-12-31 01:30:13 -07:00
parent a5cad284a8
commit df4da817b6
5 changed files with 11 additions and 11 deletions

View file

@ -4819,7 +4819,7 @@ namespace TShockAPI
return;
}
args.Player.SendSuccessMessage("Online Players ({0}/{1})", TShock.Utils.ActivePlayers(), TShock.Config.MaxSlots);
args.Player.SendSuccessMessage("Online Players ({0}/{1})", TShock.Utils.GetActivePlayerCount(), TShock.Config.MaxSlots);
var players = new List<string>();

View file

@ -1892,7 +1892,7 @@ namespace TShockAPI
if (OnGetSection(args.Player, args.Data, args.Data.ReadInt32(), args.Data.ReadInt32()))
return true;
if (TShock.Utils.ActivePlayers() + 1 > TShock.Config.MaxSlots &&
if (TShock.Utils.GetActivePlayerCount() + 1 > TShock.Config.MaxSlots &&
!args.Player.HasPermission(Permissions.reservedslot))
{
args.Player.Kick(TShock.Config.ServerFullReason, true, true);

View file

@ -144,7 +144,7 @@ namespace TShockAPI
return new JsonData()
{
port = Terraria.Netplay.ListenPort,
currentPlayers = TShock.Utils.ActivePlayers(),
currentPlayers = TShock.Utils.GetActivePlayerCount(),
maxPlayers = TShock.Config.MaxSlots,
systemRam = GetTotalSystemRam(ServerApi.RunningMono),
version = TShock.VersionNum.ToString(),

View file

@ -1241,7 +1241,7 @@ namespace TShockAPI
var player = new TSPlayer(args.Who);
if (Utils.ActivePlayers() + 1 > Config.MaxSlots + Config.ReservedSlots)
if (Utils.GetActivePlayerCount() + 1 > Config.MaxSlots + Config.ReservedSlots)
{
player.Kick(Config.ServerFullNoReservedReason, true, true, null, false);
args.Handled = true;
@ -1400,7 +1400,7 @@ namespace TShockAPI
}
// The last player will leave after this hook is executed.
if (Utils.ActivePlayers() == 1)
if (Utils.GetActivePlayerCount() == 1)
{
if (Config.SaveWorldOnLastPlayerExit)
SaveManager.Instance.SaveWorld();
@ -1621,7 +1621,7 @@ namespace TShockAPI
if (Config.EnableGeoIP && TShock.Geo != null)
{
Log.Info("{0} ({1}) from '{2}' group from '{3}' joined. ({4}/{5})", player.Name, player.IP,
player.Group.Name, player.Country, TShock.Utils.ActivePlayers(),
player.Group.Name, player.Country, TShock.Utils.GetActivePlayerCount(),
TShock.Config.MaxSlots);
if (!player.SilentJoinInProgress)
Utils.Broadcast(string.Format("{0} ({1}) has joined.", player.Name, player.Country), Color.Yellow);
@ -1629,7 +1629,7 @@ namespace TShockAPI
else
{
Log.Info("{0} ({1}) from '{2}' group joined. ({3}/{4})", player.Name, player.IP,
player.Group.Name, TShock.Utils.ActivePlayers(), TShock.Config.MaxSlots);
player.Group.Name, TShock.Utils.GetActivePlayerCount(), TShock.Config.MaxSlots);
if (!player.SilentJoinInProgress)
Utils.Broadcast(player.Name + " has joined.", Color.Yellow);
}

View file

@ -153,7 +153,7 @@ namespace TShockAPI
/// Gets the number of active players on the server.
/// </summary>
/// <returns>The number of active players on the server.</returns>
public int ActivePlayers()
public int GetActivePlayerCount()
{
return Main.player.Where(p => null != p && p.active).Count();
}
@ -1117,7 +1117,7 @@ namespace TShockAPI
}
else
{
invasionSize = 100 + (TShock.Config.InvasionMultiplier * ActivePlayers());
invasionSize = 100 + (TShock.Config.InvasionMultiplier * GetActivePlayerCount());
}
// Order matters
@ -1151,12 +1151,12 @@ namespace TShockAPI
}
/// <summary>Updates the console title with some pertinent information.</summary>
/// <param name="empty">If the server is empty; determines if we should use Utils.ActivePlayers() for player count or 0.</param>
/// <param name="empty">If the server is empty; determines if we should use Utils.GetActivePlayerCount() for player count or 0.</param>
internal void SetConsoleTitle(bool empty)
{
Console.Title = string.Format("{0}{1}/{2} on {3} @ {4}:{5} (TShock for Terraria v{6})",
!string.IsNullOrWhiteSpace(TShock.Config.ServerName) ? TShock.Config.ServerName + " - " : "",
empty ? 0 : ActivePlayers(),
empty ? 0 : GetActivePlayerCount(),
TShock.Config.MaxSlots, Main.worldName, Netplay.ServerIP.ToString(), Netplay.ListenPort, TShock.VersionNum);
}