GetMinRankWithAllPermissions() private method

private GetMinRankWithAllPermissions ( ) : Rank
return Rank
Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        /// <summary> Prints "This command requires ___+ rank" message. </summary>
        /// <param name="permissions"> List of permissions required for the command. </param>
        /// <exception cref="ArgumentNullException"> permissions is null. </exception>
        /// <exception cref="ArgumentException"> permissions array is empty. </exception>
        public void MessageNoAccess([NotNull] params Permission[] permissions)
        {
            if (permissions == null)
            {
                throw new ArgumentNullException("permissions");
            }
            if (permissions.Length == 0)
            {
                throw new ArgumentException("At least one permission required.", "permissions");
            }
            Rank reqRank = RankManager.GetMinRankWithAllPermissions(permissions);

            if (reqRank == null)
            {
                Message("None of the ranks have permissions for this command.");
            }
            else
            {
                Message("This command requires {0}+&S rank.",
                        reqRank.ClassyName);
            }
        }