EventArgs used for the PlayerHooks.PlayerPermission event.
Inheritance: System.ComponentModel.HandledEventArgs
コード例 #1
0
ファイル: PlayerHooks.cs プロジェクト: jaenudin86/TShock
        /// <summary>
        /// Fires the <see cref="PlayerPermission"/> event.
        /// </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, string permission)
        {
            if (PlayerPermission == null)
            {
                return(false);
            }

            var args = new PlayerPermissionEventArgs(player, permission);

            PlayerPermission(args);
            return(args.Handled);
        }
コード例 #2
0
        /// <summary>
        /// Fires the <see cref="PlayerPermission"/> event.
        /// </summary>
        /// <param name="player">The player firing the event.</param>
        /// <returns>Event result if the event has been handled, otherwise <see cref="PermissionHookResult.Unhandled"/>.</returns>
        public static PermissionHookResult OnPlayerPermission(TSPlayer player, string permission)
        {
            if (PlayerPermission == null)
            {
                return(PermissionHookResult.Unhandled);
            }

            var args = new PlayerPermissionEventArgs(player, permission);

            PlayerPermission(args);

            return(args.Result);
        }
コード例 #3
0
ファイル: CTRS.cs プロジェクト: Enerdy/CTRSystem
		void OnPlayerPermission(PlayerPermissionEventArgs e)
		{
			// If the player isn't logged it, he's certainly not a contributor
			if (e.Player == null || !e.Player.IsLoggedIn || !e.Player.ContainsData(Contributor.DataKey))
				return;

			Contributor con = e.Player.GetData<Contributor>(Contributor.DataKey);
			#region DEBUG
#if DEBUG
			//TShock.Log.ConsoleInfo("[" + e.Player.Index + "] Checking permission for: " + e.Permission);
#endif
			#endregion

			Tier tier = Tiers.Get(con.Tier);
			e.Handled = tier.Permissions.HasPermission(e.Permission);
			#region DEBUG
#if DEBUG
			if (e.Handled)
				TShock.Log.ConsoleInfo("OnPlayerPermission: Contributor had the permission");
#endif
			#endregion
		}
コード例 #4
0
ファイル: PlayerHooks.cs プロジェクト: NyxStudios/TShock
        /// <summary>
        /// Fires the <see cref="PlayerPermission"/> event.
        /// </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, string permission)
        {
            if (PlayerPermission == null)
                return false;

            var args = new PlayerPermissionEventArgs(player, permission);
            PlayerPermission(args);
            return args.Handled;
        }
コード例 #5
0
        /// <summary>
        /// Internal hook, fired whenever <see cref="TSPlayer.HasPermission(string)"/> is invoked.
        /// </summary>
        /// <param name="args">The <see cref="PlayerPermissionEventArgs"/> object.</param>
        private void OnPlayerPermission(PlayerPermissionEventArgs args)
        {
            // Return if the event was already handled by another plugin.
            if (args.Handled)
            {
                return;
            }

            // Ensure the player is not null and has special permissions.
            if (args.Player == null || args.Player.GetPlayerInfo() == null)
            {
                return;
            }

            // Handle the event.
            args.Handled = args.Player.GetPlayerInfo().HasPermission(args.Permission);
        }