New anti spam for liquids and projectiles
Revamped anti spam systems New liquid security
This commit is contained in:
parent
c11b944735
commit
d01426e2b1
5 changed files with 118 additions and 43 deletions
|
|
@ -193,6 +193,12 @@ namespace TShockAPI
|
|||
[Description("Disable/Revert a player if they exceed this number of tile places within 1 second.")]
|
||||
public int TilePlaceThreshold = 20;
|
||||
|
||||
[Description("Disable a player if they exceed this number of liquid sets within 1 second.")]
|
||||
public int TileLiquidThreshold = 15;
|
||||
|
||||
[Description("Disable a player if they exceed this number of projectile new within 1 second.")]
|
||||
public int ProjectileThreshold = 100;
|
||||
|
||||
[Description("Require all players to register or login before being allowed to play.")]
|
||||
public bool RequireLogin = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -521,7 +521,27 @@ namespace TShockAPI
|
|||
return true;
|
||||
}
|
||||
|
||||
if(type == 1)
|
||||
if (args.Player.TileKillThreshold >= TShock.Config.TileKillThreshold)
|
||||
{
|
||||
args.Player.LastThreat = DateTime.UtcNow;
|
||||
args.Player.SendTileSquare(tileX, tileY);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.Player.TilePlaceThreshold >= TShock.Config.TilePlaceThreshold)
|
||||
{
|
||||
args.Player.LastThreat = DateTime.UtcNow;
|
||||
args.Player.SendTileSquare(tileX, tileY);
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
|
||||
{
|
||||
args.Player.SendTileSquare(tileX, tileY);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (type == 1 && !args.Player.Group.HasPermission(Permissions.ignoreplacetiledetection))
|
||||
{
|
||||
args.Player.TilePlaceThreshold++;
|
||||
var coords = new Vector2(tileX, tileY);
|
||||
|
|
@ -529,7 +549,7 @@ namespace TShockAPI
|
|||
args.Player.TilesCreated.Add(coords, Main.tile[tileX, tileY]);
|
||||
}
|
||||
|
||||
if ((type == 0 || type == 4) && Main.tileSolid[Main.tile[tileX, tileY].type])
|
||||
if ((type == 0 || type == 4) && Main.tileSolid[Main.tile[tileX, tileY].type] && !args.Player.Group.HasPermission(Permissions.ignorekilltiledetection))
|
||||
{
|
||||
args.Player.TileKillThreshold++;
|
||||
var coords = new Vector2(tileX, tileY);
|
||||
|
|
@ -537,12 +557,6 @@ namespace TShockAPI
|
|||
args.Player.TilesDestroyed.Add(coords, Main.tile[tileX, tileY]);
|
||||
}
|
||||
|
||||
if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
|
||||
{
|
||||
args.Player.SendTileSquare(tileX, tileY);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -718,12 +732,14 @@ namespace TShockAPI
|
|||
|
||||
if (args.Player.Index != owner)
|
||||
{
|
||||
args.Player.LastThreat = DateTime.UtcNow;
|
||||
args.Player.SendData(PacketTypes.ProjectileNew, "", index);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (dmg > 175)
|
||||
{
|
||||
args.Player.LastThreat = DateTime.UtcNow;
|
||||
args.Player.SendData(PacketTypes.ProjectileNew, "", index);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -741,6 +757,24 @@ namespace TShockAPI
|
|||
return true;
|
||||
}
|
||||
|
||||
if (args.Player.ProjectileThreshold >= TShock.Config.ProjectileThreshold)
|
||||
{
|
||||
args.Player.LastThreat = DateTime.UtcNow;
|
||||
args.Player.SendData(PacketTypes.ProjectileNew, "", index);
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
|
||||
{
|
||||
args.Player.SendData(PacketTypes.ProjectileNew, "", index);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!args.Player.Group.HasPermission(Permissions.ignoreprojectiledetection))
|
||||
{
|
||||
args.Player.ProjectileThreshold++;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -751,6 +785,7 @@ namespace TShockAPI
|
|||
|
||||
if (args.Player.Index != owner)
|
||||
{
|
||||
args.Player.LastThreat = DateTime.UtcNow;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -765,6 +800,7 @@ namespace TShockAPI
|
|||
|
||||
if (args.Player.Index != Main.projectile[index].owner)
|
||||
{
|
||||
args.Player.LastThreat = DateTime.UtcNow;
|
||||
args.Player.SendData(PacketTypes.ProjectileNew, "", index);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -782,6 +818,12 @@ namespace TShockAPI
|
|||
return true;
|
||||
}
|
||||
|
||||
if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
|
||||
{
|
||||
args.Player.SendData(PacketTypes.ProjectileNew, "", index);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -831,35 +873,38 @@ namespace TShockAPI
|
|||
return true;
|
||||
}
|
||||
|
||||
if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
|
||||
if (args.Player.TileLiquidThreshold >= TShock.Config.TileLiquidThreshold)
|
||||
{
|
||||
args.Player.LastThreat = DateTime.UtcNow;
|
||||
args.Player.SendTileSquare(tileX, tileY);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool bucket = false;
|
||||
for (int i = 0; i < 49; i++)
|
||||
if (!args.Player.Group.HasPermission(Permissions.ignoreliquidsetdetection))
|
||||
{
|
||||
if (args.TPlayer.inventory[i].type >= 205 && args.TPlayer.inventory[i].type <= 207)
|
||||
{
|
||||
bucket = true;
|
||||
break;
|
||||
}
|
||||
args.Player.TileLiquidThreshold++;
|
||||
}
|
||||
if (!bucket)
|
||||
|
||||
int bucket = 0;
|
||||
if (args.TPlayer.inventory[args.TPlayer.selectedItem].type == 206)
|
||||
{
|
||||
bucket = 1;
|
||||
}
|
||||
else if (args.TPlayer.inventory[args.TPlayer.selectedItem].type == 207)
|
||||
{
|
||||
bucket = 2;
|
||||
}
|
||||
|
||||
if (lava && bucket != 2 && !args.Player.Group.HasPermission(Permissions.usebanneditem) && TShock.Itembans.ItemIsBanned("Lava Bucket"))
|
||||
{
|
||||
args.Player.LastThreat = DateTime.UtcNow;
|
||||
args.Player.SendTileSquare(tileX, tileY);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (lava && !args.Player.Group.HasPermission(Permissions.usebanneditem) && TShock.Itembans.ItemIsBanned("Lava Bucket"))
|
||||
{
|
||||
args.Player.SendTileSquare(tileX, tileY);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!lava && !args.Player.Group.HasPermission(Permissions.usebanneditem) && TShock.Itembans.ItemIsBanned("Water Bucket"))
|
||||
if (!lava && bucket != 1 && !args.Player.Group.HasPermission(Permissions.usebanneditem) && TShock.Itembans.ItemIsBanned("Water Bucket"))
|
||||
{
|
||||
args.Player.LastThreat = DateTime.UtcNow;
|
||||
args.Player.SendTileSquare(tileX, tileY);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -870,7 +915,13 @@ namespace TShockAPI
|
|||
return true;
|
||||
}
|
||||
|
||||
if (TShock.CheckRangePermission(args.Player, tileX, tileY))
|
||||
if (TShock.CheckRangePermission(args.Player, tileX, tileY, 16))
|
||||
{
|
||||
args.Player.SendTileSquare(tileX, tileY);
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
|
||||
{
|
||||
args.Player.SendTileSquare(tileX, tileY);
|
||||
return true;
|
||||
|
|
@ -895,6 +946,7 @@ namespace TShockAPI
|
|||
|
||||
if (Main.tile[tileX, tileY].type != 0x15 && (!TShock.Utils.MaxChests() && Main.tile[tileX, tileY].type != 0)) //Chest
|
||||
{
|
||||
args.Player.LastThreat = DateTime.UtcNow;
|
||||
args.Player.SendTileSquare(tileX, tileY);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1298,6 +1350,7 @@ namespace TShockAPI
|
|||
args.TPlayer.buffTime[i] = 0;
|
||||
}
|
||||
}
|
||||
NetMessage.SendData((int)PacketTypes.PlayerBuff, -1, args.Player.Index, "", args.Player.Index);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,12 @@ namespace TShockAPI
|
|||
[Description("Prevents you from being reverted by place tile abuse detection")]
|
||||
public static readonly string ignoreplacetiledetection;
|
||||
|
||||
[Description("Prevents you from being disabled by liquid set abuse detection")]
|
||||
public static readonly string ignoreliquidsetdetection;
|
||||
|
||||
[Description("Prevents you from being disabled by liquid set abuse detection")]
|
||||
public static readonly string ignoreprojectiledetection;
|
||||
|
||||
[Description("Prevents you from being reverted by no clip detection")]
|
||||
public static readonly string ignorenoclipdetection;
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ namespace TShockAPI
|
|||
public static readonly TSPlayer All = new TSPlayer("All");
|
||||
public int TileKillThreshold { get; set; }
|
||||
public int TilePlaceThreshold { get; set; }
|
||||
public int TileLiquidThreshold { get; set; }
|
||||
public int ProjectileThreshold { get; set; }
|
||||
public Dictionary<Vector2, Tile> TilesDestroyed { get; protected set; }
|
||||
public Dictionary<Vector2, Tile> TilesCreated { get; protected set; }
|
||||
public bool SyncHP { get; set; }
|
||||
|
|
|
|||
|
|
@ -474,26 +474,44 @@ namespace TShockAPI
|
|||
{
|
||||
if (player.TileKillThreshold >= Config.TileKillThreshold)
|
||||
{
|
||||
player.LastThreat = DateTime.UtcNow;
|
||||
TSPlayer.Server.RevertTiles(player.TilesDestroyed);
|
||||
}
|
||||
if (player.TileKillThreshold > 0)
|
||||
{
|
||||
player.TileKillThreshold = 0;
|
||||
player.TilesDestroyed.Clear();
|
||||
}
|
||||
}
|
||||
if (player.TileKillThreshold > 0)
|
||||
{
|
||||
player.TileKillThreshold = 0;
|
||||
}
|
||||
if (player.TilesCreated != null)
|
||||
{
|
||||
if (player.TilePlaceThreshold >= Config.TilePlaceThreshold)
|
||||
{
|
||||
player.LastThreat = DateTime.UtcNow;
|
||||
TSPlayer.Server.RevertTiles(player.TilesCreated);
|
||||
}
|
||||
if (player.TilePlaceThreshold > 0)
|
||||
{
|
||||
player.TilePlaceThreshold = 0;
|
||||
player.TilesCreated.Clear();
|
||||
}
|
||||
}
|
||||
if (player.TilePlaceThreshold > 0)
|
||||
{
|
||||
player.TilePlaceThreshold = 0;
|
||||
}
|
||||
if(player.TileLiquidThreshold >= Config.TileLiquidThreshold)
|
||||
{
|
||||
player.LastThreat = DateTime.UtcNow;
|
||||
}
|
||||
if (player.TileLiquidThreshold > 0)
|
||||
{
|
||||
player.TileLiquidThreshold = 0;
|
||||
}
|
||||
if (player.ProjectileThreshold >= Config.ProjectileThreshold)
|
||||
{
|
||||
player.LastThreat = DateTime.UtcNow;
|
||||
}
|
||||
if (player.ProjectileThreshold > 0)
|
||||
{
|
||||
player.ProjectileThreshold = 0;
|
||||
}
|
||||
if (player.ForceSpawn && (DateTime.Now - player.LastDeath).Seconds >= 3)
|
||||
{
|
||||
player.Spawn();
|
||||
|
|
@ -984,16 +1002,6 @@ namespace TShockAPI
|
|||
|
||||
public static bool CheckTilePermission(TSPlayer player, int tileX, int tileY)
|
||||
{
|
||||
if (player.TileKillThreshold >= Config.TileKillThreshold && !player.Group.HasPermission(Permissions.ignorekilltiledetection))
|
||||
{
|
||||
player.LastThreat = DateTime.UtcNow;
|
||||
return true;
|
||||
}
|
||||
if (player.TilePlaceThreshold >= Config.TilePlaceThreshold && !player.Group.HasPermission(Permissions.ignoreplacetiledetection))
|
||||
{
|
||||
player.LastThreat = DateTime.UtcNow;
|
||||
return true;
|
||||
}
|
||||
if (!player.Group.HasPermission(Permissions.canbuild))
|
||||
{
|
||||
player.SendMessage("You do not have permission to build!", Color.Red);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue