Merge pull request #330 from k0rd/master
Messy changes to prevent being spammed with permission denied changes
This commit is contained in:
commit
a6cf55229d
2 changed files with 58 additions and 10 deletions
|
|
@ -76,6 +76,10 @@ namespace TShockAPI
|
||||||
public bool RequiresPassword;
|
public bool RequiresPassword;
|
||||||
public bool SilentKickInProgress;
|
public bool SilentKickInProgress;
|
||||||
public List<Point> IceTiles;
|
public List<Point> IceTiles;
|
||||||
|
public long RPm=1;
|
||||||
|
public long WPm=1;
|
||||||
|
public long SPm=1;
|
||||||
|
public long BPm=1;
|
||||||
|
|
||||||
|
|
||||||
public bool RealPlayer
|
public bool RealPlayer
|
||||||
|
|
@ -678,4 +682,4 @@ namespace TShockAPI
|
||||||
return inventory;
|
return inventory;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1100,7 +1100,11 @@ namespace TShockAPI
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.BPm) > 2000){
|
||||||
player.SendMessage("You do not have permission to build!", Color.Red);
|
player.SendMessage("You do not have permission to build!", Color.Red);
|
||||||
|
player.BPm=DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
|
||||||
|
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1109,22 +1113,34 @@ namespace TShockAPI
|
||||||
player.IceTiles.Add(new Point(tileX, tileY));
|
player.IceTiles.Add(new Point(tileX, tileY));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.BPm) > 2000){
|
||||||
|
player.SendMessage("You do not have permission to build!", Color.Red);
|
||||||
|
player.BPm=DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
|
||||||
|
|
||||||
player.SendMessage("You do not have permission to build!", Color.Red);
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!player.Group.HasPermission(Permissions.editspawn) && !Regions.CanBuild(tileX, tileY, player) &&
|
if (!player.Group.HasPermission(Permissions.editspawn) && !Regions.CanBuild(tileX, tileY, player) &&
|
||||||
Regions.InArea(tileX, tileY))
|
Regions.InArea(tileX, tileY))
|
||||||
{
|
{
|
||||||
player.SendMessage("Region protected from changes.", Color.Red);
|
if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.RPm) > 2000){
|
||||||
|
player.SendMessage("Region protected from changes.", Color.Red);
|
||||||
|
player.RPm=DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
|
||||||
|
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (Config.DisableBuild)
|
if (Config.DisableBuild)
|
||||||
{
|
{
|
||||||
if (!player.Group.HasPermission(Permissions.editspawn))
|
if (!player.Group.HasPermission(Permissions.editspawn))
|
||||||
{
|
{
|
||||||
player.SendMessage("World protected from changes.", Color.Red);
|
if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.WPm) > 2000){
|
||||||
|
player.SendMessage("World protected from changes.", Color.Red);
|
||||||
|
player.WPm=DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
|
||||||
|
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1134,8 +1150,12 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
var flag = CheckSpawn(tileX, tileY);
|
var flag = CheckSpawn(tileX, tileY);
|
||||||
if (flag)
|
if (flag)
|
||||||
{
|
{
|
||||||
|
if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.SPm) > 2000){
|
||||||
player.SendMessage("Spawn protected from changes.", Color.Red);
|
player.SendMessage("Spawn protected from changes.", Color.Red);
|
||||||
|
player.SPm=DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
|
||||||
|
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1147,20 +1167,39 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
if (!player.Group.HasPermission(Permissions.canbuild))
|
if (!player.Group.HasPermission(Permissions.canbuild))
|
||||||
{
|
{
|
||||||
player.SendMessage("You do not have permission to build!", Color.Red);
|
if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.BPm) > 2000){
|
||||||
|
player.SendMessage("You do not have permission to build!", Color.Red);
|
||||||
|
player.BPm=DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!player.Group.HasPermission(Permissions.editspawn) && !Regions.CanBuild(tileX, tileY, player) &&
|
if (!player.Group.HasPermission(Permissions.editspawn) && !Regions.CanBuild(tileX, tileY, player) &&
|
||||||
Regions.InArea(tileX, tileY))
|
Regions.InArea(tileX, tileY))
|
||||||
{
|
{
|
||||||
player.SendMessage("Region protected from changes.", Color.Red);
|
|
||||||
|
|
||||||
|
if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.RPm) > 2000){
|
||||||
|
player.SendMessage("Region protected from changes.", Color.Red);
|
||||||
|
player.RPm=DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (Config.DisableBuild)
|
if (Config.DisableBuild)
|
||||||
{
|
{
|
||||||
if (!player.Group.HasPermission(Permissions.editspawn))
|
if (!player.Group.HasPermission(Permissions.editspawn))
|
||||||
{
|
{
|
||||||
player.SendMessage("World protected from changes.", Color.Red);
|
if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.WPm) > 2000){
|
||||||
|
player.SendMessage("World protected from changes.", Color.Red);
|
||||||
|
player.WPm=DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1171,14 +1210,19 @@ namespace TShockAPI
|
||||||
var flag = CheckSpawn(tileX, tileY);
|
var flag = CheckSpawn(tileX, tileY);
|
||||||
if (flag)
|
if (flag)
|
||||||
{
|
{
|
||||||
player.SendMessage("Spawn protected from changes.", Color.Red);
|
if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.SPm) > 1000){
|
||||||
|
player.SendMessage("Spawn protected from changes.", Color.Red);
|
||||||
|
player.SPm=DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool CheckSpawn(int x, int y)
|
public static bool CheckSpawn(int x, int y)
|
||||||
{
|
{
|
||||||
Vector2 tile = new Vector2(x, y);
|
Vector2 tile = new Vector2(x, y);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue