From 5c9639c9c15737e0caa5ca7730b868c185c96b14 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sun, 1 Jan 2012 01:53:03 -0700 Subject: [PATCH] Add PlayerBuff hook --- TShockAPI/GetDataHandlers.cs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index daaed2d3..bc0685ac 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -497,6 +497,29 @@ namespace TShockAPI return args.Handled; } + public class PlayerBuffEventArgs : HandledEventArgs + { + public byte ID { get; set; } + public byte Type { get; set; } + public short Time { get; set; } + } + public static HandlerList PlayerBuff; + + private static bool OnPlayerBuff(byte id, byte type, short time) + { + if (PlayerBuff == null) + return false; + + var args = new PlayerBuffEventArgs + { + ID = id, + Type = type, + Time = time, + }; + PlayerBuff.Invoke(null, args); + return args.Handled; + } + #endregion public static void InitGetDataHandler() { @@ -1769,6 +1792,9 @@ namespace TShockAPI var type = args.Data.ReadInt8(); var time = args.Data.ReadInt16(); + if (OnPlayerBuff(id, type, time)) + return true; + if (TShock.CheckIgnores(args.Player)) { args.Player.SendData(PacketTypes.PlayerBuff, "", id);