示例#1
0
 // The old method didn't work for superadmin, sadly :(
 public static bool CheckPermissions(this TShockAPI.Group group, List <string> perms)
 {
     foreach (var perm in perms)
     {
         if (group.HasPermission(perm))
         {
             return(true);
         }
     }
     return(false);
 }
示例#2
0
        public static int GetDynamicPermission(this Group group, string root)
        {
            if (group.HasPermission(root + ".*"))
            {
                return(Int32.MaxValue);
            }

            int max   = 0;
            var regex = new Regex("^" + root.Replace(".", @"\.") + @"\.(\d+)$");

            foreach (string permission in group.TotalPermissions)
            {
                Match match = regex.Match(permission);
                if (match.Success && match.Value == permission)
                {
                    max = Math.Max(max, Convert.ToInt32(match.Groups[1].Value));
                }
            }

            return(max == 0 && group.HasPermission(root) ? 1 : max);
        }
        /// <summary>
        ///   Returns the number in the end of the permission.
        /// </summary>
        /// <param name="group">A TShock group.</param>
        /// <param name="root">Root of permission (part before number)</param>
        /// <returns></returns>
        public static int GetDynamicPermission(this Group group, string root)
        {
            if (group.HasPermission(root + ".*") || group.HasPermission("*"))
            {
                return(short.MaxValue);
            }

            var max   = 0;
            var regex = new Regex("^" + root.Replace(".", @"\.") + @"\.(\d+)$");

            foreach (var permission in group.TotalPermissions)
            {
                var match = regex.Match(permission);
                if (match.Success && match.Value == permission)
                {
                    max = Math.Max(max, Convert.ToInt32(match.Groups[1].Value));
                }
            }

            return(max == 0 ? SummonLimit.MaxSummons : max);
        }