fCraft.RankManager.GetMinRankWithAllPermissions C# (CSharp) Method

GetMinRankWithAllPermissions() private method

private GetMinRankWithAllPermissions ( ) : Rank
return Rank
        public static Rank GetMinRankWithAllPermissions( [NotNull] params Permission[] permissions ) {
            if( permissions == null ) throw new ArgumentNullException( "permissions" );
            for( int r = Ranks.Count - 1; r >= 0; r-- ) {
                int r1 = r;
                if( permissions.All( t => Ranks[r1].Can( t ) ) ) {
                    return Ranks[r];
                }
            }
            return null;
        }

Usage Example

        internal static void ThrowPermissionMissing([NotNull] Player player, [CanBeNull] PlayerInfo target,
                                                    [NotNull] string action, [NotNull] params Permission[] permissions)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }
            if (permissions == null)
            {
                throw new ArgumentNullException("permissions");
            }
            Rank   minRank = RankManager.GetMinRankWithAllPermissions(permissions);
            string msg, colorMsg;

            if (minRank != null)
            {
                msg = String.Format("You need to be ranked {0}+ to {1}.",
                                    minRank.Name, action);
                colorMsg = String.Format("&SYou need to be ranked {0}&S+ to {1}.",
                                         minRank.ClassyName, action);
            }
            else
            {
                msg      = String.Format("No one is allowed to {0} on this server.", action);
                colorMsg = String.Format("&SNo one is allowed to {0} on this server.", action);
            }

            throw new PlayerOpException(player, target, PlayerOpExceptionCode.PermissionMissing, msg, colorMsg);
        }
All Usage Examples Of fCraft.RankManager::GetMinRankWithAllPermissions