Using TShock.Players instead of Terraria.Main.Players
This commit is contained in:
parent
a8df558fe2
commit
36b33891c9
3 changed files with 29 additions and 34 deletions
|
|
@ -669,7 +669,8 @@ namespace TShockAPI
|
|||
|
||||
if (tsplr.Group.HasPermission("adminchat") && !text.StartsWith("/"))
|
||||
{
|
||||
Tools.Broadcast(ConfigurationManager.AdminChatPrefix + "<" + tsplr.Name + "> " + text, (byte)ConfigurationManager.AdminChatRGB[0], (byte)ConfigurationManager.AdminChatRGB[1], (byte)ConfigurationManager.AdminChatRGB[2]);
|
||||
Tools.Broadcast(ConfigurationManager.AdminChatPrefix + "<" + tsplr.Name + "> " + text,
|
||||
(byte)ConfigurationManager.AdminChatRGB[0], (byte)ConfigurationManager.AdminChatRGB[1], (byte)ConfigurationManager.AdminChatRGB[2]);
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
|
@ -800,29 +801,29 @@ namespace TShockAPI
|
|||
private void OnUpdate(GameTime time)
|
||||
{
|
||||
UpdateManager.UpdateProcedureCheck();
|
||||
for (int i = 0; i < Main.maxPlayers; i++)
|
||||
foreach (TSPlayer player in TShock.Players)
|
||||
{
|
||||
if (Main.player[i].active == false)
|
||||
continue;
|
||||
TSPlayer player = Players[i];
|
||||
if (player.TileThreshold >= 20)
|
||||
if (player != null && player.Active)
|
||||
{
|
||||
if (Tools.HandleTntUser(player, "Kill tile abuse detected."))
|
||||
if (player.TileThreshold >= 20)
|
||||
{
|
||||
RevertKillTile(player);
|
||||
player.TileThreshold = 0;
|
||||
player.TilesDestroyed.Clear();
|
||||
if (Tools.HandleTntUser(player, "Kill tile abuse detected."))
|
||||
{
|
||||
RevertKillTile(player);
|
||||
player.TileThreshold = 0;
|
||||
player.TilesDestroyed.Clear();
|
||||
}
|
||||
else if (player.TileThreshold > 0)
|
||||
{
|
||||
player.TileThreshold = 0;
|
||||
player.TilesDestroyed.Clear();
|
||||
}
|
||||
|
||||
}
|
||||
else if (player.TileThreshold > 0)
|
||||
{
|
||||
player.TileThreshold = 0;
|
||||
player.TilesDestroyed.Clear();
|
||||
}
|
||||
|
||||
}
|
||||
else if (player.TileThreshold > 0)
|
||||
{
|
||||
player.TileThreshold = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,15 +62,15 @@ namespace TShockAPI
|
|||
public static string GetPlayers()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (int i = 0; i < Main.maxPlayers; i++)
|
||||
foreach (TSPlayer player in TShock.Players)
|
||||
{
|
||||
if (Main.player[i].active)
|
||||
if (player != null && player.Active)
|
||||
{
|
||||
if (sb.Length != 0)
|
||||
{
|
||||
sb.Append(", ");
|
||||
}
|
||||
sb.Append(Main.player[i].name);
|
||||
sb.Append(player.Name);
|
||||
}
|
||||
}
|
||||
return sb.ToString();
|
||||
|
|
@ -125,14 +125,10 @@ namespace TShockAPI
|
|||
{
|
||||
Log.Info(log);
|
||||
TSPlayer.Server.SendMessage(log, color);
|
||||
for (int i = 0; i < Main.maxPlayers; i++)
|
||||
foreach (TSPlayer player in TShock.Players)
|
||||
{
|
||||
if (TShock.Players[i] == null)
|
||||
continue;
|
||||
if (!TShock.Players[i].Group.HasPermission("logs"))
|
||||
continue;
|
||||
|
||||
TShock.Players[i].SendMessage(log, color);
|
||||
if (player != null && player.Group.HasPermission("logs"))
|
||||
player.SendMessage(log, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -143,9 +139,9 @@ namespace TShockAPI
|
|||
public static int ActivePlayers()
|
||||
{
|
||||
int num = 0;
|
||||
for (int i = 0; i < Main.maxPlayers; i++)
|
||||
foreach (TSPlayer player in TShock.Players)
|
||||
{
|
||||
if (Main.player[i].active)
|
||||
if (player != null && player.Active)
|
||||
{
|
||||
num++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,16 +73,14 @@ namespace TShockAPI
|
|||
|
||||
public static void NotifyAdministrators(string[] changes)
|
||||
{
|
||||
for (int i = 0; i < Main.maxPlayers; i++)
|
||||
foreach (TSPlayer player in TShock.Players)
|
||||
{
|
||||
if (Main.player[i].active)
|
||||
if (player != null && player.Active && player.Group.HasPermission("maintenance"))
|
||||
{
|
||||
if (!TShock.Players[i].Group.HasPermission("maintenance"))
|
||||
return;
|
||||
TShock.Players[i].SendMessage("The server is out of date. To update, type /updatenow.");
|
||||
player.SendMessage("The server is out of date. To update, type /updatenow.");
|
||||
for (int j = 4; j < changes.Length; j++)
|
||||
{
|
||||
TShock.Players[i].SendMessage(changes[j], Color.Red);
|
||||
player.SendMessage(changes[j], Color.Red);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue