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("/"))
|
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;
|
e.Handled = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -800,29 +801,29 @@ namespace TShockAPI
|
||||||
private void OnUpdate(GameTime time)
|
private void OnUpdate(GameTime time)
|
||||||
{
|
{
|
||||||
UpdateManager.UpdateProcedureCheck();
|
UpdateManager.UpdateProcedureCheck();
|
||||||
for (int i = 0; i < Main.maxPlayers; i++)
|
foreach (TSPlayer player in TShock.Players)
|
||||||
{
|
{
|
||||||
if (Main.player[i].active == false)
|
if (player != null && player.Active)
|
||||||
continue;
|
|
||||||
TSPlayer player = Players[i];
|
|
||||||
if (player.TileThreshold >= 20)
|
|
||||||
{
|
{
|
||||||
if (Tools.HandleTntUser(player, "Kill tile abuse detected."))
|
if (player.TileThreshold >= 20)
|
||||||
{
|
{
|
||||||
RevertKillTile(player);
|
if (Tools.HandleTntUser(player, "Kill tile abuse detected."))
|
||||||
player.TileThreshold = 0;
|
{
|
||||||
player.TilesDestroyed.Clear();
|
RevertKillTile(player);
|
||||||
|
player.TileThreshold = 0;
|
||||||
|
player.TilesDestroyed.Clear();
|
||||||
|
}
|
||||||
|
else if (player.TileThreshold > 0)
|
||||||
|
{
|
||||||
|
player.TileThreshold = 0;
|
||||||
|
player.TilesDestroyed.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (player.TileThreshold > 0)
|
else if (player.TileThreshold > 0)
|
||||||
{
|
{
|
||||||
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()
|
public static string GetPlayers()
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
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)
|
if (sb.Length != 0)
|
||||||
{
|
{
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
}
|
}
|
||||||
sb.Append(Main.player[i].name);
|
sb.Append(player.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
|
|
@ -125,14 +125,10 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
Log.Info(log);
|
Log.Info(log);
|
||||||
TSPlayer.Server.SendMessage(log, color);
|
TSPlayer.Server.SendMessage(log, color);
|
||||||
for (int i = 0; i < Main.maxPlayers; i++)
|
foreach (TSPlayer player in TShock.Players)
|
||||||
{
|
{
|
||||||
if (TShock.Players[i] == null)
|
if (player != null && player.Group.HasPermission("logs"))
|
||||||
continue;
|
player.SendMessage(log, color);
|
||||||
if (!TShock.Players[i].Group.HasPermission("logs"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
TShock.Players[i].SendMessage(log, color);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -143,9 +139,9 @@ namespace TShockAPI
|
||||||
public static int ActivePlayers()
|
public static int ActivePlayers()
|
||||||
{
|
{
|
||||||
int num = 0;
|
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++;
|
num++;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,16 +73,14 @@ namespace TShockAPI
|
||||||
|
|
||||||
public static void NotifyAdministrators(string[] changes)
|
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"))
|
player.SendMessage("The server is out of date. To update, type /updatenow.");
|
||||||
return;
|
|
||||||
TShock.Players[i].SendMessage("The server is out of date. To update, type /updatenow.");
|
|
||||||
for (int j = 4; j < changes.Length; j++)
|
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