Example #1
0
        public bool AllowGroup(string item, string name)
        {
            string  groupsNew = "";
            ItemBan b         = GetItemBanByName(item);

            if (b != null)
            {
                try
                {
                    groupsNew = String.Join(",", b.AllowedGroups);
                    if (groupsNew.Length > 0)
                    {
                        groupsNew += ",";
                    }
                    groupsNew += name;
                    b.SetAllowedGroups(groupsNew);

                    int q = database.Query("UPDATE ItemBans SET AllowedGroups=@0 WHERE ItemName=@1", groupsNew,
                                           item);

                    return(q > 0);
                }
                catch (Exception ex)
                {
                    TShock.Log.Error(ex.ToString());
                }
            }

            return(false);
        }
Example #2
0
        public void UpdateItemBans()
        {
            ItemBans.Clear();

            using (var reader = database.QueryReader("SELECT * FROM ItemBans"))
            {
                while (reader != null && reader.Read())
                {
                    ItemBan ban = new ItemBan(reader.Get <string>("ItemName"));
                    ban.SetAllowedGroups(reader.Get <string>("AllowedGroups"));
                    ItemBans.Add(ban);
                }
            }
        }