Implement cooldown warnings on build permissions
This commit is contained in:
parent
8a88fd1642
commit
bfbe58e9ed
1 changed files with 12 additions and 17 deletions
|
|
@ -377,6 +377,12 @@ namespace TShockAPI
|
||||||
if (!shouldWarnPlayer)
|
if (!shouldWarnPlayer)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// Space out warnings by 2 seconds so that they don't get spammed.
|
||||||
|
if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - lastPermissionWarning) < 2000)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// If they should be warned, warn them.
|
// If they should be warned, warn them.
|
||||||
switch (failure)
|
switch (failure)
|
||||||
{
|
{
|
||||||
|
|
@ -391,6 +397,9 @@ namespace TShockAPI
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the last warning time to now.
|
||||||
|
lastPermissionWarning = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -449,24 +458,10 @@ namespace TShockAPI
|
||||||
public List<Point> IceTiles;
|
public List<Point> IceTiles;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unused, can be removed.
|
/// The last time the player was warned for build permissions.
|
||||||
|
/// In MS, defaults to 1 (so it will warn on the first attempt).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long RPm = 1;
|
public long lastPermissionWarning = 1;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// World protection message cool down.
|
|
||||||
/// </summary>
|
|
||||||
public long WPm = 1;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Spawn protection message cool down.
|
|
||||||
/// </summary>
|
|
||||||
public long SPm = 1;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Permission to build message cool down.
|
|
||||||
/// </summary>
|
|
||||||
public long BPm = 1;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The time in ms when the player has logged in.
|
/// The time in ms when the player has logged in.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue