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); }
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); } } }