Merge pull request #710 from Thraka/general-devel

Added player reference to the ChestOpenEventArgs
This commit is contained in:
MarioE 2013-11-02 10:43:48 -07:00
commit d4c9d4566c

View file

@ -715,13 +715,18 @@ namespace TShockAPI
/// Y location of said chest /// Y location of said chest
/// </summary> /// </summary>
public int Y { get; set; } public int Y { get; set; }
/// <summary>
/// The player opening the chest
/// </summary>
public TSPlayer Player { get; set; }
} }
/// <summary> /// <summary>
/// ChestOpen - Called when any chest is opened /// ChestOpen - Called when any chest is opened
/// </summary> /// </summary>
public static HandlerList<ChestOpenEventArgs> ChestOpen; public static HandlerList<ChestOpenEventArgs> ChestOpen;
private static bool OnChestOpen(int x, int y) private static bool OnChestOpen(int x, int y, TSPlayer player)
{ {
if (ChestOpen == null) if (ChestOpen == null)
return false; return false;
@ -730,6 +735,7 @@ namespace TShockAPI
{ {
X = x, X = x,
Y = y, Y = y,
Player = player,
}; };
ChestOpen.Invoke(null, args); ChestOpen.Invoke(null, args);
return args.Handled; return args.Handled;
@ -2752,7 +2758,7 @@ namespace TShockAPI
var x = args.Data.ReadInt32(); var x = args.Data.ReadInt32();
var y = args.Data.ReadInt32(); var y = args.Data.ReadInt32();
if (OnChestOpen(x, y)) if (OnChestOpen(x, y, args.Player))
return true; return true;
if (TShock.CheckIgnores(args.Player)) if (TShock.CheckIgnores(args.Player))