EventArgs used for the PlayerHooks.PlayerPermission event.
Наследование: System.ComponentModel.HandledEventArgs
Пример #1
0
        /// <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
		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
        /// <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;
        }
        /// <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);
        }