public AccessResult Check(string name, LevelPermission rank)
        {
            if (Blacklisted.CaselessContains(name))
            {
                return(AccessResult.Blacklisted);
            }
            if (Whitelisted.CaselessContains(name))
            {
                return(AccessResult.Whitelisted);
            }

            if (rank < Min)
            {
                return(AccessResult.BelowMinRank);
            }
            if (rank > Max && MaxCmd != null && !CommandExtraPerms.Find(MaxCmd, 1).UsableBy(rank))
            {
                return(AccessResult.AboveMaxRank);
            }
            return(AccessResult.Allowed);
        }
Beispiel #2
0
        /// <summary> Allows a player to access these permissions. </summary>
        /// <returns> true if the target is whitelisted, false if the given player
        /// had insufficient permission to whitelist the target. </returns>
        public bool Whitelist(Player p, string target)
        {
            if (!CheckList(p, target, true))
            {
                return(false);
            }
            if (Whitelisted.CaselessContains(target))
            {
                Player.Message(p, "\"{0}\" is already whitelisted.", target); return(true);
            }

            bool removed = true;

            if (!Blacklisted.CaselessRemove(target))
            {
                Whitelisted.Add(target);
                removed = false;
            }
            OnListChanged(p, target, true, removed);
            return(true);
        }
Beispiel #3
0
        /// <summary> Returns the allowed state for the given player. </summary>
        public AccessResult Check(string name, Group rank)
        {
            if (Blacklisted.CaselessContains(name))
            {
                return(AccessResult.Blacklisted);
            }
            if (Whitelisted.CaselessContains(name))
            {
                return(AccessResult.Whitelisted);
            }

            if (rank.Permission < Min)
            {
                return(AccessResult.BelowMinRank);
            }
            if (rank.Permission > Max && MaxCmd != null && rank.Permission < CommandExtraPerms.MinPerm(MaxCmd))
            {
                return(AccessResult.AboveMaxRank);
            }
            return(AccessResult.Allowed);
        }
        public bool Whitelist(Player p, LevelPermission plRank, Level lvl, string target)
        {
            if (!CheckList(p, plRank, target, true))
            {
                return(false);
            }
            if (Whitelisted.CaselessContains(target))
            {
                p.Message("{0} %Sis already whitelisted.", p.FormatNick(target));
                return(true);
            }

            bool removed = true;

            if (!Blacklisted.CaselessRemove(target))
            {
                Whitelisted.Add(target);
                removed = false;
            }
            OnListChanged(p, lvl, target, true, removed);
            return(true);
        }
Beispiel #5
0
        /// <summary> Returns the allowed state for the given player. </summary>
        public LevelAccess Check(Player p)
        {
            if (Blacklisted.CaselessContains(p.name))
            {
                return(LevelAccess.Blacklisted);
            }
            if (Whitelisted.CaselessContains(p.name))
            {
                return(LevelAccess.Whitelisted);
            }

            if (p.Rank < Min)
            {
                return(LevelAccess.BelowMinRank);
            }
            string maxCmd = IsVisit ? "pervisitmax" : "perbuildmax";

            if (p.Rank > Max && !p.group.CanExecute(maxCmd))
            {
                return(LevelAccess.AboveMaxRank);
            }
            return(LevelAccess.Allowed);
        }