From 81fff9bd667dae8b9ce6ada372a8ab0fcbe76a5f Mon Sep 17 00:00:00 2001 From: Enerdy Date: Mon, 11 Jan 2016 22:34:22 +0000 Subject: [PATCH] Pass down the permission being checked to the EventArgs (thanks @white) --- TShockAPI/Hooks/PlayerHooks.cs | 15 +++++++++++---- TShockAPI/TSPlayer.cs | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/TShockAPI/Hooks/PlayerHooks.cs b/TShockAPI/Hooks/PlayerHooks.cs index 473d2d6d..b3e6b585 100644 --- a/TShockAPI/Hooks/PlayerHooks.cs +++ b/TShockAPI/Hooks/PlayerHooks.cs @@ -149,13 +149,20 @@ namespace TShockAPI.Hooks /// public TSPlayer Player { get; set; } + /// + /// The permission being checked. + /// + public string Permission { get; set; } + /// /// Initializes a new instance of the PlayerPermissionEventArgs class. /// - /// - public PlayerPermissionEventArgs(TSPlayer player) + /// The player who fired the event. + /// The permission being checked. + public PlayerPermissionEventArgs(TSPlayer player, string permission) { Player = player; + Permission = permission; } } @@ -320,12 +327,12 @@ namespace TShockAPI.Hooks /// /// The player firing the event. /// True if the event has been handled. - 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; } diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 9baa358d..30e9a591 100755 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -963,7 +963,7 @@ namespace TShockAPI /// True if the player has that permission. 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);