Added a hook for when pvp is toggled.

This commit is contained in:
Lucas Nicodemus 2011-12-31 13:14:54 -07:00
parent 5ba0efb5cc
commit 761b023907

View file

@ -51,6 +51,10 @@ namespace TShockAPI
private static Dictionary<PacketTypes, GetDataHandlerDelegate> GetDataHandlerDelegates;
public static int[] WhitelistBuffMaxTime;
#region Events
/// <summary>
/// TileEdit - called when a tile is placed or destroyed
/// </summary>
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<TogglePvpEventArgs> 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)
{