List of included and excluded players.
Exemplo n.º 1
0
 void UpdatePlayerListCache()
 {
     lock ( locker ) {
         ExceptionList = new PlayerExceptions(includedPlayers.Values.ToArray(),
                                              excludedPlayers.Values.ToArray());
     }
 }
Exemplo n.º 2
0
        /// <summary> Checks player's permission status with this controller, in detail. </summary>
        /// <param name="info"> Player to check. </param>
        /// <returns> Security check result. </returns>
        public SecurityCheckResult CheckDetailed([NotNull] PlayerInfo info)
        {
            // ReSharper disable LoopCanBeConvertedToQuery
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }
            PlayerExceptions listCache = ExceptionList;

            for (int i = 0; i < listCache.Excluded.Length; i++)
            {
                if (listCache.Excluded[i] == info)
                {
                    return(SecurityCheckResult.BlackListed);
                }
            }

            if (info.Rank >= MinRank /*&& player.info.rank <= maxRank*/)  // TODO: implement maxrank
            {
                return(SecurityCheckResult.Allowed);
            }

            for (int i = 0; i < listCache.Included.Length; i++)
            {
                if (listCache.Included[i] == info)
                {
                    return(SecurityCheckResult.WhiteListed);
                }
            }

            return(SecurityCheckResult.RankTooLow);
            // ReSharper restore LoopCanBeConvertedToQuery
        }
Exemplo n.º 3
0
        /// <summary> Checks whether a player is allowed by this controller. </summary>
        /// <param name="info"> Player to check. </param>
        /// <returns> True if player is allowed. </returns>
        public bool Check([NotNull] PlayerInfo info)
        {
            // ReSharper disable LoopCanBeConvertedToQuery
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }
            PlayerExceptions listCache = ExceptionList;

            for (int i = 0; i < listCache.Excluded.Length; i++)
            {
                if (listCache.Excluded[i] == info)
                {
                    return(false);
                }
            }

            if (info.Rank >= MinRank /*&& player.info.rank <= maxRank*/)
            {
                return(true);                                                          // TODO: implement maxrank
            }
            for (int i = 0; i < listCache.Included.Length; i++)
            {
                if (listCache.Included[i] == info)
                {
                    return(true);
                }
            }

            return(false);
            // ReSharper restore LoopCanBeConvertedToQuery
        }
Exemplo n.º 4
0
        /// <summary> Checks player's permission status with this controller, in detail. </summary>
        /// <param name="info"> Player to check. </param>
        /// <returns> Security check result. </returns>
        public SecurityCheckResult CheckDetailed([NotNull] PlayerInfo info)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }
            PlayerExceptions listCache = ExceptionList;

            for (int i = 0; i < listCache.Excluded.Length; i++)
            {
                if (listCache.Excluded[i] == info)
                {
                    return(SecurityCheckResult.BlackListed);
                }
            }

            if (info.Rank >= MinRank)
            {
                return(SecurityCheckResult.Allowed);
            }

            for (int i = 0; i < listCache.Included.Length; i++)
            {
                if (listCache.Included[i] == info)
                {
                    return(SecurityCheckResult.WhiteListed);
                }
            }

            return(SecurityCheckResult.RankTooLow);
        }
Exemplo n.º 5
0
        /// <summary> Checks whether a player is allowed by this controller. </summary>
        /// <param name="info"> Player to check. </param>
        /// <returns> True if player is allowed. </returns>
        public bool Check([NotNull] PlayerInfo info)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }
            PlayerExceptions listCache = ExceptionList;

            for (int i = 0; i < listCache.Excluded.Length; i++)
            {
                if (listCache.Excluded[i] == info)
                {
                    return(false);
                }
            }

            if (info.Rank >= MinRank)
            {
                return(true);
            }

            for (int i = 0; i < listCache.Included.Length; i++)
            {
                if (listCache.Included[i] == info)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 6
0
        static void ZoneInfoHandler(Player player, CommandReader cmd)
        {
            string zoneName = cmd.Next();

            if (zoneName == null)
            {
                player.Message("No zone name specified. See &H/Help ZInfo");
                return;
            }

            Zone zone = player.WorldMap.Zones.Find(zoneName);

            if (zone == null)
            {
                player.MessageNoZone(zoneName);
                return;
            }

            player.Message("About zone \"{0}\": size {1} x {2} x {3}, contains {4} blocks, editable by {5}+.",
                           zone.Name,
                           zone.Bounds.Width, zone.Bounds.Length, zone.Bounds.Height,
                           zone.Bounds.Volume,
                           zone.Controller.MinRank.ClassyName);

            player.Message("  Zone center is at ({0},{1},{2}).",
                           (zone.Bounds.XMin + zone.Bounds.XMax) / 2,
                           (zone.Bounds.YMin + zone.Bounds.YMax) / 2,
                           (zone.Bounds.ZMin + zone.Bounds.ZMax) / 2);

            if (zone.CreatedBy != null)
            {
                player.Message("  Zone created by {0}&S on {1:MMM d} at {1:h:mm} ({2} ago).",
                               zone.CreatedByClassy,
                               zone.CreatedDate,
                               DateTime.UtcNow.Subtract(zone.CreatedDate).ToMiniString());
            }

            if (zone.EditedBy != null)
            {
                player.Message("  Zone last edited by {0}&S on {1:MMM d} at {1:h:mm} ({2}d {3}h ago).",
                               zone.EditedByClassy,
                               zone.EditedDate,
                               DateTime.UtcNow.Subtract(zone.EditedDate).Days,
                               DateTime.UtcNow.Subtract(zone.EditedDate).Hours);
            }

            PlayerExceptions zoneExceptions = zone.ExceptionList;

            if (zoneExceptions.Included.Length > 0)
            {
                player.Message("  Zone whitelist includes: {0}",
                               zoneExceptions.Included.JoinToClassyString());
            }

            if (zoneExceptions.Excluded.Length > 0)
            {
                player.Message("  Zone blacklist excludes: {0}",
                               zoneExceptions.Excluded.JoinToClassyString());
            }
        }
Exemplo n.º 7
0
        /// <summary> Creates a description string of the controller. </summary>
        /// <param name="target"> Name of the object that owns this controller. </param>
        /// <param name="noun"> The type of target (e.g. "world" or "zone"). </param>
        /// <param name="verb"> The action, in past tense, that this
        /// controller manages (e.g. "accessed" or "modified"). </param>
        public string GetDescription([NotNull] IClassy target, [NotNull] string noun, [NotNull] string verb)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            if (noun == null)
            {
                throw new ArgumentNullException("noun");
            }
            if (verb == null)
            {
                throw new ArgumentNullException("verb");
            }
            PlayerExceptions list = ExceptionList;

            StringBuilder message = new StringBuilder(noun);

            message[0] = Char.ToUpper(message[0]);   // capitalize first letter.

            if (HasRankRestriction)
            {
                message.AppendFormat(" {0}&S can only be {1} by {2}+&S",
                                     target.ClassyName,
                                     verb,
                                     MinRank.ClassyName);
            }
            else
            {
                message.AppendFormat(" {0}&S can be {1} by anyone",
                                     target.ClassyName,
                                     verb);
            }

            if (list.Included.Length > 0)
            {
                message.AppendFormat(" and {0}&S", list.Included.JoinToClassyString());
            }

            if (list.Excluded.Length > 0)
            {
                message.AppendFormat(", except {0}&S", list.Excluded.JoinToClassyString());
            }

            message.Append('.');
            return(message.ToString());
        }
Exemplo n.º 8
0
 void UpdatePlayerListCache() {
     lock( locker ) {
         ExceptionList = new PlayerExceptions( includedPlayers.Values.ToArray(),
                                               excludedPlayers.Values.ToArray() );
     }
 }