Esempio n. 1
0
        static CommandExtraPerms Add(string cmd, int num, string desc, LevelPermission min,
                                     List <LevelPermission> allowed, List <LevelPermission> disallowed)
        {
            CommandExtraPerms perms = new CommandExtraPerms(cmd, num, desc, min, allowed, disallowed);

            list.Add(perms);
            return(perms);
        }
Esempio n. 2
0
        /// <summary> Creates a copy of this instance. </summary>
        public CommandExtraPerms Copy()
        {
            CommandExtraPerms perms = new CommandExtraPerms();

            perms.CmdName     = CmdName;
            perms.MinRank     = MinRank;
            perms.Description = Description;
            perms.Number      = Number;
            return(perms);
        }
Esempio n. 3
0
 /// <summary> Sets the nth extra permission for the given command. </summary>
 public static void Set(string cmd, int num, string desc, LevelPermission min,
                        List<LevelPermission> allowed, List<LevelPermission> disallowed) {
     CommandExtraPerms perms = Find(cmd, num);
     if (perms == null) {
         Add(cmd, num, desc, min, allowed, disallowed);
     } else {
         perms.CmdName = cmd; perms.Num = num;
         if (!String.IsNullOrEmpty(desc)) perms.Desc = desc;
         perms.Init(min, allowed, disallowed);
     }
 }
Esempio n. 4
0
        static void LoadExtraPerm(string[] args)
        {
            string cmdName = args[0];
            int    number = int.Parse(args[1]), minPerm = int.Parse(args[2]);
            string desc = args[3] == null ? "" : args[3];

            CommandExtraPerms existing = Find(cmdName, number);

            if (existing != null)
            {
                desc = existing.Description;
            }
            Set(cmdName, (LevelPermission)minPerm, desc, number);
        }
Esempio n. 5
0
        /// <summary> Sets the nth extra permission for a given command. </summary>
        public static void Set(string cmd, LevelPermission perm, string desc, int num = 1)
        {
            if (perm > LevelPermission.Nobody)
            {
                return;
            }

            // add or replace existing
            CommandExtraPerms perms = Find(cmd, num);

            if (perms == null)
            {
                perms = new CommandExtraPerms(); list.Add(perms);
            }

            perms.CmdName     = cmd;
            perms.MinRank     = perm;
            perms.Description = desc;
            perms.Number      = num;
        }
Esempio n. 6
0
        public CommandExtraPerms Copy()
        {
            CommandExtraPerms copy = new CommandExtraPerms(CmdName, Num, Desc, 0, null, null);

            CopyTo(copy); return(copy);
        }
Esempio n. 7
0
        /// <summary> Returns the lowest rank that has the nth extra permission for a given command. </summary>
        /// <returns> defPerm if the nth extra permission does not exist, otherwise the lowest rank. </returns>
        public static LevelPermission MinPerm(string cmd, LevelPermission defPerm, int num = 1)
        {
            CommandExtraPerms perms = Find(cmd, num);

            return(perms == null ? defPerm : perms.MinRank);
        }