Move OnPlayerAnimation to Bouncer
This commit is contained in:
parent
d03e899452
commit
cdba07c62e
3 changed files with 31 additions and 16 deletions
|
|
@ -76,6 +76,7 @@ Putting this stuff down here so things don't conflict as often.
|
|||
* Added `TSPlayer` to `GetDataHandlers.PlayerBuff`. (@hakusaro)
|
||||
* Added `TSPlayer` and `PlayerDeathReason` to `GetDataHandlers.PlayerDamage`. (@hakusaro)
|
||||
* Added `TSPlayer` to `GetDataHandlers.NPCStrike`. (@hakusaro)
|
||||
* Added `TSPlayer` to `GetDataHandlers.PlayerAnimation`. (@hakusaro)
|
||||
|
||||
## TShock 4.3.25
|
||||
* Fixed a critical exploit in the Terraria protocol that could cause massive unpreventable world corruption as well as a number of other problems. Thanks to @bartico6 for reporting. Fixed by the efforts of @QuiCM, @hakusaro, and tips in the right directioon from @bartico6.
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ namespace TShockAPI
|
|||
{
|
||||
// Setup hooks
|
||||
|
||||
GetDataHandlers.PlayerAnimation.Register(OnPlayerAnimation);
|
||||
GetDataHandlers.NPCStrike.Register(OnNPCStrike);
|
||||
GetDataHandlers.ItemDrop.Register(OnItemDrop);
|
||||
GetDataHandlers.PlayerBuff.Register(OnPlayerBuff);
|
||||
|
|
@ -59,6 +60,26 @@ namespace TShockAPI
|
|||
GetDataHandlers.TileEdit.Register(OnTileEdit);
|
||||
}
|
||||
|
||||
/// <summary>Handles basic animation throttling for disabled players.</summary>
|
||||
/// <param name="sender">sender</param>
|
||||
/// <param name="args">args</param>
|
||||
internal void OnPlayerAnimation(object sender, GetDataHandlers.PlayerAnimationEventArgs args)
|
||||
{
|
||||
if (TShock.CheckIgnores(args.Player))
|
||||
{
|
||||
args.Player.SendData(PacketTypes.PlayerAnimation, "", args.Player.Index);
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
|
||||
{
|
||||
args.Player.SendData(PacketTypes.PlayerAnimation, "", args.Player.Index);
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Handles the NPC Strike event for Bouncer.</summary>
|
||||
/// <param name="sender">The object that triggered the event.</param>
|
||||
/// <param name="args">The packet arguments that the event has.</param>
|
||||
|
|
@ -69,7 +90,7 @@ namespace TShockAPI
|
|||
short damage = args.Damage;
|
||||
float knockback = args.Knockback;
|
||||
byte crit = args.Critical;
|
||||
|
||||
|
||||
if (Main.npc[id] == null)
|
||||
{
|
||||
args.Handled = true;
|
||||
|
|
|
|||
|
|
@ -1298,6 +1298,8 @@ namespace TShockAPI
|
|||
/// </summary>
|
||||
public class PlayerAnimationEventArgs : HandledEventArgs
|
||||
{
|
||||
/// <summary>The TSPlayer that triggered the event.</summary>
|
||||
public TSPlayer Player { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1305,12 +1307,15 @@ namespace TShockAPI
|
|||
/// </summary>
|
||||
public static HandlerList<PlayerAnimationEventArgs> PlayerAnimation;
|
||||
|
||||
private static bool OnPlayerAnimation()
|
||||
private static bool OnPlayerAnimation(TSPlayer player)
|
||||
{
|
||||
if (PlayerAnimation == null)
|
||||
return false;
|
||||
|
||||
var args = new PlayerAnimationEventArgs { };
|
||||
var args = new PlayerAnimationEventArgs
|
||||
{
|
||||
Player = player,
|
||||
};
|
||||
PlayerAnimation.Invoke(null, args);
|
||||
return args.Handled;
|
||||
}
|
||||
|
|
@ -2635,21 +2640,9 @@ namespace TShockAPI
|
|||
|
||||
private static bool HandlePlayerAnimation(GetDataHandlerArgs args)
|
||||
{
|
||||
if (OnPlayerAnimation())
|
||||
if (OnPlayerAnimation(args.Player))
|
||||
return true;
|
||||
|
||||
if (TShock.CheckIgnores(args.Player))
|
||||
{
|
||||
args.Player.SendData(PacketTypes.PlayerAnimation, "", args.Player.Index);
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
|
||||
{
|
||||
args.Player.SendData(PacketTypes.PlayerAnimation, "", args.Player.Index);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue