Move most of HandleProjectileKill to Bouncer
Added GetDataHandlers.ProjectileKill hook and related arguments. Fired when a projectile kill packet is accepted by the server.
This commit is contained in:
parent
2cfa633df4
commit
c5f9a51802
3 changed files with 71 additions and 14 deletions
|
|
@ -42,6 +42,7 @@ namespace TShockAPI
|
|||
{
|
||||
// Setup hooks
|
||||
|
||||
GetDataHandlers.ProjectileKill.Register(OnProjectileKill);
|
||||
GetDataHandlers.PlayerUpdate.Register(OnPlayerUpdate);
|
||||
GetDataHandlers.KillMe.Register(OnKillMe);
|
||||
GetDataHandlers.NewProjectile.Register(OnNewProjectile);
|
||||
|
|
@ -51,6 +52,33 @@ namespace TShockAPI
|
|||
GetDataHandlers.TileEdit.Register(OnTileEdit);
|
||||
}
|
||||
|
||||
/// <summary>Handles ProjectileKill events for throttling & out of bounds projectiles.</summary>
|
||||
/// <param name="sender">The object that triggered the event.</param>
|
||||
/// <param name="args">The packet arguments that the event has.</param>
|
||||
internal void OnProjectileKill(object sender, GetDataHandlers.ProjectileKillEventArgs args)
|
||||
{
|
||||
if (args.ProjectileIndex > Main.maxProjectiles || args.ProjectileIndex < 0)
|
||||
{
|
||||
// TODO: Should this be /true/ to stop the server from processing it?
|
||||
args.Handled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (TShock.CheckIgnores(args.Player))
|
||||
{
|
||||
args.Player.RemoveProjectile(args.ProjectileIdentity, args.ProjectileOwner);
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
|
||||
{
|
||||
args.Player.RemoveProjectile(args.ProjectileIdentity, args.ProjectileOwner);
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Handles disabling enforcement & minor anti-exploit stuff</summary>
|
||||
/// <param name="sender">The object that triggered the event.</param>
|
||||
/// <param name="args">The packet arguments that the event has.</param>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue