Pass down the permission being checked to the EventArgs (thanks @white)
This commit is contained in:
parent
aa419283a9
commit
81fff9bd66
2 changed files with 12 additions and 5 deletions
|
|
@ -149,13 +149,20 @@ namespace TShockAPI.Hooks
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public TSPlayer Player { get; set; }
|
public TSPlayer Player { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The permission being checked.
|
||||||
|
/// </summary>
|
||||||
|
public string Permission { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the PlayerPermissionEventArgs class.
|
/// Initializes a new instance of the PlayerPermissionEventArgs class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="player"></param>
|
/// <param name="player">The player who fired the event.</param>
|
||||||
public PlayerPermissionEventArgs(TSPlayer player)
|
/// <param name="permission">The permission being checked.</param>
|
||||||
|
public PlayerPermissionEventArgs(TSPlayer player, string permission)
|
||||||
{
|
{
|
||||||
Player = player;
|
Player = player;
|
||||||
|
Permission = permission;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -320,12 +327,12 @@ namespace TShockAPI.Hooks
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="player">The player firing the event.</param>
|
/// <param name="player">The player firing the event.</param>
|
||||||
/// <returns>True if the event has been handled.</returns>
|
/// <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)
|
if (PlayerPermission == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var args = new PlayerPermissionEventArgs(player);
|
var args = new PlayerPermissionEventArgs(player, permission);
|
||||||
PlayerPermission(args);
|
PlayerPermission(args);
|
||||||
return args.Handled;
|
return args.Handled;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -963,7 +963,7 @@ namespace TShockAPI
|
||||||
/// <returns>True if the player has that permission.</returns>
|
/// <returns>True if the player has that permission.</returns>
|
||||||
public bool HasPermission(string permission)
|
public bool HasPermission(string permission)
|
||||||
{
|
{
|
||||||
if (PlayerHooks.OnPlayerPermission(this))
|
if (PlayerHooks.OnPlayerPermission(this, permission))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return (tempGroup != null && tempGroup.HasPermission(permission)) || Group.HasPermission(permission);
|
return (tempGroup != null && tempGroup.HasPermission(permission)) || Group.HasPermission(permission);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue