Adds 1 sec delay between each notification of Area protected (no more spam)

This commit is contained in:
Twitchy 2011-07-03 17:48:20 +12:00
parent 31cf5c1ae7
commit 2a6454f60b
2 changed files with 18 additions and 4 deletions

View file

@ -261,7 +261,11 @@ namespace TShockAPI
}
if (!args.Player.Group.HasPermission("editspawn") && RegionManager.InProtectedArea(x, y, Tools.GetPlayerIP(args.Player.Name)))
{
args.Player.SendMessage("Region protected from changes.", Color.Red);
if ((DateTime.UtcNow - args.Player.LastTileChangeNotify).TotalMilliseconds > 1000)
{
args.Player.SendMessage("Region protected from changes.", Color.Red);
args.Player.LastTileChangeNotify = DateTime.UtcNow;
}
args.Player.SendTileSquare(x, y);
return true;
}
@ -269,7 +273,11 @@ namespace TShockAPI
{
if (!args.Player.Group.HasPermission("editspawn"))
{
args.Player.SendMessage("World protected from changes.", Color.Red);
if ((DateTime.UtcNow - args.Player.LastTileChangeNotify).TotalMilliseconds > 1000)
{
args.Player.SendMessage("World protected from changes.", Color.Red);
args.Player.LastTileChangeNotify = DateTime.UtcNow;
}
args.Player.SendTileSquare(x, y);
return true;
}
@ -281,8 +289,12 @@ namespace TShockAPI
var flag = TShock.CheckSpawn(x, y);
if (flag)
{
args.Player.SendMessage("Spawn protected from changes.", Color.Red);
args.Player.SendTileSquare(x, y);
if ((DateTime.UtcNow - args.Player.LastTileChangeNotify).TotalMilliseconds > 1000)
{
args.Player.SendMessage("Spawn protected from changes.", Color.Red);
args.Player.LastTileChangeNotify = DateTime.UtcNow;
}
args.Player.SendTileSquare(x, y);
return true;
}
}

View file

@ -37,6 +37,7 @@ namespace TShockAPI
public DateTime LastPvpChange { get; protected set; }
public Rectangle TempArea = new Rectangle();
public DateTime LastExplosive { get; set; }
public DateTime LastTileChangeNotify { get; set; }
public bool InitSpawn = false;
public bool DisplayLogs = true;
public Vector2 oldSpawn = Vector2.Zero;
@ -159,6 +160,7 @@ namespace TShockAPI
//The error occurs when a tile trys to update which the client hasnt load yet, Clients only update tiles withen 150 blocks
//Try 300 if it does not work (Higher number - Longer load times - Less chance of error)
SendTileSquare(tileX, tileY, 150);
if (TPlayer.SpawnX > 0 && TPlayer.SpawnY > 0)
{
int spX = TPlayer.SpawnX;