Pass down the permission being checked to the EventArgs (thanks @white)

This commit is contained in:
Enerdy 2016-01-11 22:34:22 +00:00
parent aa419283a9
commit 81fff9bd66
2 changed files with 12 additions and 5 deletions

View file

@ -149,13 +149,20 @@ namespace TShockAPI.Hooks
/// </summary>
public TSPlayer Player { get; set; }
/// <summary>
/// The permission being checked.
/// </summary>
public string Permission { get; set; }
/// <summary>
/// Initializes a new instance of the PlayerPermissionEventArgs class.
/// </summary>
/// <param name="player"></param>
public PlayerPermissionEventArgs(TSPlayer player)
/// <param name="player">The player who fired the event.</param>
/// <param name="permission">The permission being checked.</param>
public PlayerPermissionEventArgs(TSPlayer player, string permission)
{
Player = player;
Permission = permission;
}
}
@ -320,12 +327,12 @@ namespace TShockAPI.Hooks
/// </summary>
/// <param name="player">The player firing the event.</param>
/// <returns>True if the event has been handled.</returns>
public static bool OnPlayerPermission(TSPlayer player)
public static bool OnPlayerPermission(TSPlayer player, string permission)
{
if (PlayerPermission == null)
return false;
var args = new PlayerPermissionEventArgs(player);
var args = new PlayerPermissionEventArgs(player, permission);
PlayerPermission(args);
return args.Handled;
}

View file

@ -963,7 +963,7 @@ namespace TShockAPI
/// <returns>True if the player has that permission.</returns>
public bool HasPermission(string permission)
{
if (PlayerHooks.OnPlayerPermission(this))
if (PlayerHooks.OnPlayerPermission(this, permission))
return true;
return (tempGroup != null && tempGroup.HasPermission(permission)) || Group.HasPermission(permission);