From 761b023907f08e256f5c743d3f85def38c0c7c49 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 31 Dec 2011 13:14:54 -0700 Subject: [PATCH] Added a hook for when pvp is toggled. --- TShockAPI/GetDataHandlers.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index bb8c4b4d..3e63f0bd 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -51,6 +51,10 @@ namespace TShockAPI private static Dictionary GetDataHandlerDelegates; public static int[] WhitelistBuffMaxTime; #region Events + + /// + /// TileEdit - called when a tile is placed or destroyed + /// public class TileEditEventArgs : HandledEventArgs { public int X { get; set; } @@ -74,6 +78,27 @@ namespace TShockAPI TileEdit.Invoke(null, args); return args.Handled; } + + public class TogglePvpEventArgs : HandledEventArgs + { + public int id { get; set; } + public bool pvp { get; set; } + } + + public static HandlerList TogglePvp; + public static bool OnPvpToggled(int _id, bool _pvp) + { + if (TogglePvp == null) + return false; + + var args = new TogglePvpEventArgs + { + id = _id, + pvp = _pvp, + }; + TogglePvp.Invoke(null, args); + return args.Handled; + } #endregion public static void InitGetDataHandler() { @@ -724,6 +749,8 @@ namespace TShockAPI { int id = args.Data.ReadByte(); bool pvp = args.Data.ReadBoolean(); + if (OnPvpToggled(id, pvp)) + return true; if (id != args.Player.Index) {