Esempio n. 1
0
        public void Describe(Player p, StringBuilder perms)
        {
            perms.Append(Group.GetColoredName(Min) + "%S+");
            if (Max != LevelPermission.Nobody)
            {
                perms.Append(" up to " + Group.GetColoredName(Max));
            }

            List <string> whitelist = Whitelisted;

            foreach (string name in whitelist)
            {
                perms.Append(", " + p.FormatNick(name));
            }

            List <string> blacklist = Blacklisted;

            if (blacklist.Count == 0)
            {
                return;
            }

            perms.Append(" %S(except ");
            foreach (string name in blacklist)
            {
                perms.Append(p.FormatNick(name) + ", ");
            }
            perms.Remove(perms.Length - 2, 2);
            perms.Append("%S)");
        }
Esempio n. 2
0
        public static void PrintCommandInfo(Player p, Command cmd)
        {
            var           perms   = GrpCommands.allowedCommands.Find(C => C.commandName == cmd.name);
            StringBuilder builder = new StringBuilder();

            builder.Append("Usable by: ");
            if (perms == null)
            {
                builder.Append(Group.GetColoredName(cmd.defaultRank) + "%S+");
            }
            else
            {
                PrintRanks(perms.lowestRank, perms.allow, perms.disallow, builder);
            }
            Player.Message(p, builder.ToString());

            PrintAliases(p, cmd);
            CommandPerm[] addPerms = cmd.ExtraPerms;
            if (addPerms == null)
            {
                return;
            }

            Player.Message(p, "%TExtra permissions:");
            for (int i = 0; i < addPerms.Length; i++)
            {
                var             extra = CommandOtherPerms.Find(cmd, i + 1);
                LevelPermission perm  = (LevelPermission)extra.Permission;
                Player.Message(p, "{0}) {1}%S{2}", i + 1, Group.GetColoredName(perm), extra.Description);
            }
        }
Esempio n. 3
0
        public static void PrintCommandInfo(Player p, Command cmd)
        {
            CommandPerms  perms   = CommandPerms.Find(cmd.name);
            StringBuilder builder = new StringBuilder();

            builder.Append("Usable by: ");
            if (perms == null)
            {
                builder.Append(Group.GetColoredName(cmd.defaultRank) + "%S+");
            }
            else
            {
                PrintRanks(perms.MinRank, perms.Allowed, perms.Disallowed, builder);
            }
            Player.Message(p, builder.ToString());

            PrintAliases(p, cmd);
            List <CommandExtraPerms> extraPerms = CommandExtraPerms.FindAll(cmd.name);

            if (extraPerms.Count == 0)
            {
                return;
            }

            Player.Message(p, "%TExtra permissions:");
            foreach (CommandExtraPerms extra in extraPerms)
            {
                Player.Message(p, "{0}) {1}%S{2}", extra.Number,
                               Group.GetColoredName(extra.MinRank), extra.Description);
            }
        }
Esempio n. 4
0
        public bool CheckDetailed(Player p, bool ignoreRankPerm = false)
        {
            AccessResult result = Check(p);

            if (result == AccessResult.Allowed)
            {
                return(true);
            }
            if (result == AccessResult.Whitelisted)
            {
                return(true);
            }
            if (result == AccessResult.AboveMaxRank && ignoreRankPerm)
            {
                return(true);
            }
            if (result == AccessResult.BelowMinRank && ignoreRankPerm)
            {
                return(true);
            }

            if (result == AccessResult.Blacklisted)
            {
                Player.Message(p, "You are blacklisted from {0} {1}", ActionIng, ColoredName);
                return(false);
            }

            string whitelist = "";

            if (Whitelisted.Count > 0)
            {
                whitelist = "(and " + Whitelisted.Join(pl => PlayerInfo.GetColoredName(p, pl)) + "%S) ";
            }

            if (result == AccessResult.BelowMinRank)
            {
                Player.Message(p, "Only {2}%S+ {3}may {0} {1}",
                               Action, ColoredName, Group.GetColoredName(Min), whitelist);
            }
            else if (result == AccessResult.AboveMaxRank)
            {
                Player.Message(p, "Only {2} %Sand below {3}may{0} {1}",
                               Action, ColoredName, Group.GetColoredName(Max), whitelist);
            }
            return(false);
        }
Esempio n. 5
0
        /// <summary> Returns whether the given player is allowed for these access permissions. </summary>
        /// <remarks> If the player is not allowed by these access permissions,
        /// sends a message to the player describing why they are not. </remarks>
        public bool CheckDetailed(Player p, bool ignoreRankPerm = false)
        {
            LevelAccess result = Check(p);

            if (result == LevelAccess.Allowed)
            {
                return(true);
            }
            if (result == LevelAccess.Whitelisted)
            {
                return(true);
            }
            if (result == LevelAccess.AboveMaxRank && ignoreRankPerm)
            {
                return(true);
            }
            if (result == LevelAccess.BelowMinRank && ignoreRankPerm)
            {
                return(true);
            }

            if (result == LevelAccess.Blacklisted)
            {
                string action = IsVisit ? "going to" : "building in";
                Player.Message(p, "You are blacklisted from {1} {0}%S.", lvl.ColoredName, action);
            }
            else if (result == LevelAccess.BelowMinRank)
            {
                string action = IsVisit? "go to" : "build in";
                Player.Message(p, "Only {2}%S+ may {1} {0}%S.",
                               lvl.ColoredName, action, Group.GetColoredName(Min));
            }
            else if (result == LevelAccess.AboveMaxRank)
            {
                string action = IsVisit? "go to" : "build in";
                Player.Message(p, "Only {2} %Sand below may {1} {0}%S.",
                               lvl.ColoredName, action, Group.GetColoredName(Max));
            }
            return(false);
        }
Esempio n. 6
0
        public bool CheckDetailed(Player p, LevelPermission plRank)
        {
            AccessResult access = Check(p.name, plRank);

            if (access == AccessResult.Allowed)
            {
                return(true);
            }
            if (access == AccessResult.Whitelisted)
            {
                return(true);
            }

            if (access == AccessResult.Blacklisted)
            {
                p.Message("You are blacklisted from {0} {1}", ActionIng, ColoredName);
                return(false);
            }

            string whitelist = "";

            if (Whitelisted.Count > 0)
            {
                whitelist = "(and " + Whitelisted.Join(pl => p.FormatNick(pl)) + "%S) ";
            }

            if (access == AccessResult.BelowMinRank)
            {
                p.Message("Only {2}%S+ {3}may {0} {1}",
                          Action, ColoredName, Group.GetColoredName(Min), whitelist);
            }
            else if (access == AccessResult.AboveMaxRank)
            {
                p.Message("Only {2} %Sand below {3}may {0} {1}",
                          Action, ColoredName, Group.GetColoredName(Max), whitelist);
            }
            return(false);
        }
Esempio n. 7
0
        public void Describe(StringBuilder builder)
        {
            builder.Append(Group.GetColoredName(MinRank) + "&S+");

            if (Allowed != null && Allowed.Count > 0)
            {
                foreach (LevelPermission perm in Allowed)
                {
                    builder.Append(", " + Group.GetColoredName(perm));
                }
                builder.Append("&S");
            }

            if (Disallowed != null && Disallowed.Count > 0)
            {
                builder.Append(" (except ");
                foreach (LevelPermission perm in Disallowed)
                {
                    builder.Append(Group.GetColoredName(perm) + ", ");
                }
                builder.Remove(builder.Length - 2, 2);
                builder.Append("&S)");
            }
        }
Esempio n. 8
0
        public static void PrintRanks(LevelPermission minRank, List <LevelPermission> allowed,
                                      List <LevelPermission> disallowed, StringBuilder builder)
        {
            builder.Append(Group.GetColoredName(minRank) + "%S+");
            if (allowed != null && allowed.Count > 0)
            {
                foreach (LevelPermission perm in allowed)
                {
                    builder.Append(", " + Group.GetColoredName(perm));
                }
                builder.Append("%S");
            }

            if (disallowed != null && disallowed.Count > 0)
            {
                builder.Append(" (except ");
                foreach (LevelPermission perm in disallowed)
                {
                    builder.Append(Group.GetColoredName(perm) + ", ");
                }
                builder.Remove(builder.Length - 2, 2);
                builder.Append("%S)");
            }
        }
Esempio n. 9
0
 public static void MessageNeedMinPerm(Player p, string action, LevelPermission perm)
 {
     p.Message("Only {0}%S{1}", Group.GetColoredName(perm), action);
 }