From 23dba2954590fc9d681e9dea7c4b1c1b0d4ee7a0 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sun, 1 Jan 2012 02:23:00 -0700 Subject: [PATCH] Add PlayerBuff hook This is the last hook I'm adding for the time being. If you feel that there aren't enough hooks, well request it. --- TShockAPI/GetDataHandlers.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 2e4e4fdf..10e11576 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -639,6 +639,25 @@ namespace TShockAPI return args.Handled; } + public class PlayerBuffUpdateEventArgs : HandledEventArgs + { + public byte ID { get; set; } + } + public static HandlerList PlayerBuffUpdate; + + private static bool OnPlayerBuffUpdate(byte id) + { + if (PlayerBuffUpdate == null) + return false; + + var args = new PlayerBuffUpdateEventArgs + { + ID = id, + }; + PlayerBuffUpdate.Invoke(null, args); + return args.Handled; + } + #endregion public static void InitGetDataHandler() { @@ -2140,6 +2159,10 @@ namespace TShockAPI private static bool HandlePlayerBuffUpdate(GetDataHandlerArgs args) { var id = args.Data.ReadInt8(); + + if (OnPlayerBuffUpdate(id)) + return true; + for (int i = 0; i < 10; i++) { var buff = args.Data.ReadInt8();