From 5379b393aa4858dc37b2296ab4572ae64c3bb29d Mon Sep 17 00:00:00 2001 From: Thraka Date: Sat, 2 Nov 2013 01:38:40 -0700 Subject: [PATCH] Added player reference to the ChestOpenEventArgs The ChestOpen handler doesn't have reference to the player, which makes it difficult to search through who is opening the chest. This change rectifies that by passing reference of the Player to the OnChestOpen method and then through the handler. The Player reference was already available, but not being passed. --- TShockAPI/GetDataHandlers.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 9b90b858..4e5128ac 100755 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -715,13 +715,18 @@ namespace TShockAPI /// Y location of said chest /// public int Y { get; set; } + + /// + /// The player opening the chest + /// + public TSPlayer Player { get; set; } } /// /// ChestOpen - Called when any chest is opened /// public static HandlerList ChestOpen; - private static bool OnChestOpen(int x, int y) + private static bool OnChestOpen(int x, int y, TSPlayer player) { if (ChestOpen == null) return false; @@ -730,6 +735,7 @@ namespace TShockAPI { X = x, Y = y, + Player = player, }; ChestOpen.Invoke(null, args); return args.Handled; @@ -2752,7 +2758,7 @@ namespace TShockAPI var x = args.Data.ReadInt32(); var y = args.Data.ReadInt32(); - if (OnChestOpen(x, y)) + if (OnChestOpen(x, y, args.Player)) return true; if (TShock.CheckIgnores(args.Player))