public Cooldown(int time, ScSign sign, string name, string group = null)
 {
     this.time = time;
       this.sign = sign;
       this.name = name;
       this.group = group;
 }
Example #2
0
 public Cooldown(int time, ScSign sign, string name, string group = null)
 {
     this.time  = time;
     this.sign  = sign;
     this.name  = name;
     this.group = group;
 }
Example #3
0
        /// <summary>
        /// Check if the player can create a sign.
        /// The player must have the ability to use every command they put on the sign.
        /// </summary>
        /// <param name="player">Player to check permissions with</param>
        /// <param name="sign">Sign</param>
        /// <returns></returns>
        public static bool CanCreate(TSPlayer player, ScSign sign)
        {
            if (sign.commands.Count == 0) return true;

            var fails = sign.commands.Count(cmd => !cmd.Value.CanRun(player));

            return fails != sign.commands.Values.Count;
        }
Example #4
0
 /// <summary>
 /// Check if the player can break a sign.
 /// If the player has the sign's override permission they can break it.
 /// If the player has the permission "essentials.signs.break" they can break it
 /// </summary>
 /// <param name="player"></param>
 /// <param name="sign"></param>
 /// <returns></returns>
 public static bool CanBreak(TSPlayer player, ScSign sign)
 {
     if (player.Group.HasPermission(sign.requiredPermission))
         return true;
     if (!player.Group.HasPermission("essentials.signs.break"))
         return false;
     return true;
 }
        /// <summary>
        /// Adds or modifies a dictionary value
        /// </summary>
        /// <param name="dictionary">Dictionary to edit</param>
        /// <param name="point">Sign location</param>
        /// <param name="sign">Sign</param>
        public static void AddItem(this Dictionary <Point, ScSign> dictionary, Point point, ScSign sign)
        {
            if (!dictionary.ContainsKey(point))
            {
                dictionary.Add(point, sign);
                return;
            }

            dictionary[point] = sign;
        }
Example #6
0
        /// <summary>
        /// Adds or modifies a dictionary value
        /// </summary>
        /// <param name="dictionary">Dictionary to edit</param>
        /// <param name="point">Sign location</param>
        /// <param name="sign">Sign</param>
        public static void AddItem(this Dictionary<Point, ScSign> dictionary, Point point, ScSign sign)
        {
            if (!dictionary.ContainsKey(point))
            {
                dictionary.Add(point, sign);
                return;
            }

            dictionary[point] = sign;
        }
Example #7
0
 /// <summary>
 /// Returns or adds an ScSign from a dictionary.
 /// </summary>
 /// <param name="dictionary">Dictionary to get results from</param>
 /// <param name="x">x position of sign</param>
 /// <param name="y">y position of sign</param>
 /// <param name="text">text on the sign</param>
 /// <param name="tPly">player who initiated the check</param>
 /// <returns></returns>
 public static ScSign Check(this Dictionary<Point, ScSign> dictionary, int x, int y, string text, TSPlayer tPly)
 {
     var point = new Point(x, y);
     if (!dictionary.ContainsKey(point))
     {
         var sign = new ScSign(text, tPly, point);
         dictionary.Add(point, sign);
         return sign;
     }
     return dictionary[point];
 }
        /// <summary>
        /// Returns or adds an ScSign from a dictionary.
        /// </summary>
        /// <param name="dictionary">Dictionary to get results from</param>
        /// <param name="x">x position of sign</param>
        /// <param name="y">y position of sign</param>
        /// <param name="text">text on the sign</param>
        /// <param name="tPly">player who initiated the check</param>
        /// <returns></returns>
        public static ScSign Check(this Dictionary <Point, ScSign> dictionary, int x, int y, string text, TSPlayer tPly)
        {
            var point = new Point(x, y);

            if (!dictionary.ContainsKey(point))
            {
                // not checking permissions when a sign is re-registered (after a server restart for example)
                var sign = new ScSign(text, tPly, point, checkPermissions: false);
                dictionary.Add(point, sign);
                return(sign);
            }
            return(dictionary[point]);
        }
Example #9
0
        private static bool OnSignNew(int x, int y, string text, int who, int signIndex)
        {
            if (!text.StartsWith(config.DefineSignCommands, StringComparison.CurrentCultureIgnoreCase))
            {
                return(false);
            }

            var tPly  = TShock.Players[who];
            var sPly  = ScPlayers[who];
            var point = new Point(x, y);

            if (tPly == null || sPly == null)
            {
                return(false);
            }

            if (!ScUtils.CanCreate(tPly))
            {
                SendErrorToPlayer(sPly, tPly, "You do not have the permission to create a Sign Commands sign.");
                return(true);
            }

            ScSign sign;

            try {
                sign = new ScSign(text, tPly, point);
            } catch (Exception ex) {
                SendErrorToPlayer(sPly, tPly, ex.Message);
                return(true);
            }

            if (!ScUtils.CanEdit(tPly, sign))
            {
                SendErrorToPlayer(sPly, tPly, "This sign is protected from modifications.");
                return(true);
            }

            Task.Factory.StartNew(() => {
                Thread.Sleep(10);

                // actually register the new command sign only, if the player had the permission to change the sign text.
                // This ensures that tshock (by regions) and other plugins protecting this sign have a chance to prevent the change.
                string newText      = Main.sign[signIndex].text;
                bool textWasApplied = (newText == text);
                if (textWasApplied)
                {
                    ScSigns.AddItem(point, sign);
                }
            });
            return(false);
        }
        private static bool OnSignNew(int x, int y, string text, int who)
        {
            if (!text.ToLower().StartsWith(config.DefineSignCommands.ToLower())) return false;

              var tPly = TShock.Players[who];
              var point = new Point(x, y);
              var sign = new ScSign(text, tPly, point);
              if (tPly == null)
            return false;

              if (!ScUtils.CanEdit(tPly, sign))
            return true;

              if (ScUtils.CanCreate(tPly, sign)) {
            ScSigns.AddItem(point, sign);
            return false;
              }

              tPly.SendErrorMessage("You do not have permission to create that sign command.");
              return true;
        }
 public static bool CanRead(TSPlayer player, ScSign sign)
 {
     return(!sign.noRead || player.Group.HasPermission("essentials.signs.readall"));
 }
 public static bool CanEdit(TSPlayer player, ScSign sign)
 {
     return(!sign.noEdit || player.Group.HasPermission("essentials.signs.editall"));
 }
Example #13
0
 public static bool CanRead(TSPlayer player, ScSign sign)
 {
     return !sign.noRead || player.Group.HasPermission("essentials.signs.readall");
 }
Example #14
0
 public static bool CanEdit(TSPlayer player, ScSign sign)
 {
     return !sign.noEdit || player.Group.HasPermission("essentials.signs.editall");
 }