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.
This commit is contained in:
Thraka 2013-11-02 01:38:40 -07:00
parent c54f7bd850
commit 5379b393aa

View file

@ -715,13 +715,18 @@ namespace TShockAPI
/// Y location of said chest
/// </summary>
public int Y { get; set; }
/// <summary>
/// The player opening the chest
/// </summary>
public TSPlayer Player { get; set; }
}
/// <summary>
/// ChestOpen - Called when any chest is opened
/// </summary>
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)
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))