Esempio n. 1
0
 public void RemovePrefix(string prefix)
 {
     if (!Prefixes.Contains(prefix))
     {
         throw new Exception("This is not a prefix in this server.");
     }
     else
     {
         Prefixes.Remove(prefix);
     }
 }
Esempio n. 2
0
        private void HandleOnClose(IWampConnection connection)
        {
            // Remove connection from lookup
            _connections.Remove(connection.WebSocketConnectionInfo.Id);

            // Remove prefixes
            Prefixes.Remove(connection);

            // Remove subscriptions
            foreach (var topics in Subscriptions)
            {
                topics.Value.Remove(connection);
            }
        }
Esempio n. 3
0
        public override void RemovePrefix(UserBase user, char c)
        {
            if (Prefixes.ContainsKey(user.Mask.Account))
            {
                string value = Prefixes[user.Mask.Account].Replace(c.ToString(), string.Empty);
                if (value == string.Empty)
                {
                    Prefixes.Remove(user.Mask.Account);
                }
                else
                {
                    Prefixes[user.Mask.Account] = value;
                }

                Server.Commit(this);
            }
        }
Esempio n. 4
0
        public static void ManagePrefixGroups(CommandArgs args)
        {
            bool Add = args.Parameters[0].ToLower() == "add";

            if (Add)
            {
                if (args.Parameters.Count < 5)
                {
                    args.Player.SendErrorMessage(TShock.Config.CommandSpecifier + "bprefix add group [Name] [Permission] [AllowedPrefixes (1 3 10...)]");
                    return;
                }
                string Name = args.Parameters[2];
                if (Prefixes.Any(b => b.Name == Name))
                {
                    args.Player.SendErrorMessage("Prefix group with '{0}' name already exists.", Name);
                    return;
                }
                string     Permission      = args.Parameters[3];
                List <int> AllowedPrefixes = new List <int>();
                for (int i = 4; i < args.Parameters.Count; i++)
                {
                    if (!int.TryParse(args.Parameters[i], out int PrefixID) ||
                        (PrefixID < 0) || (PrefixID > (Lang.prefix.Length - 1)))
                    {
                        args.Player.SendErrorMessage("Invalid PrefixID '{0}'!", args.Parameters[i]);
                        continue;
                    }
                    AllowedPrefixes.Add(PrefixID);
                }

                var BTP = new BTPrefix(Name, Permission, AllowedPrefixes);
                Prefixes.Add(BTP);
                BTDatabase.PAdd(BTP);
                args.Player.SendSuccessMessage("Successfully added new prefix group with given name: {0}.", Name);
            }
            else
            {
                if (args.Parameters.Count != 3)
                {
                    args.Player.SendErrorMessage(TShock.Config.CommandSpecifier + "bprefix del group [Name]");
                    return;
                }
                string Name    = args.Parameters[2];
                bool   Success = false;
                foreach (var p in Prefixes)
                {
                    if (p.Name == Name)
                    {
                        Success = true;
                        Prefixes.Remove(p);
                        break;
                    }
                }
                if (Success)
                {
                    args.Player.SendSuccessMessage("Successfully deleted prefix group with given name: {0}.", Name);
                    BTDatabase.PDelete(Name);
                }
                else
                {
                    args.Player.SendErrorMessage("Invalid PrefixGroup name!");
                }
            }
        }
Esempio n. 5
0
 public bool RemovePrefix(string p) => Prefixes.Remove(p);