public bool AllowGroup(int id, string name) { bool flag; string str = ""; BuffBan buffBanById = Koishi.BanBuff.Utils.GetBuffBanById(id); if (buffBanById != null) { try { str = string.Join(",", buffBanById.AllowedGroups); if (str.Length > 0) { str = string.Concat(str, ","); } str = string.Concat(str, name); buffBanById.SetAllowedGroups(str); IDbConnection dbConnection = this.database; object[] objArray = new object[] { str, id }; flag = DbExt.Query(dbConnection, "UPDATE BuffBans SET AllowedGroups=@0 WHERE BuffID=@1", objArray) > 0; } catch (Exception exception) { TShock.Log.Error(exception.ToString()); return(false); } return(flag); } return(false); }
public bool RemoveGroup(int id, string group) { bool flag; BuffBan buffBanById = Koishi.BanBuff.Utils.GetBuffBanById(id); if (buffBanById != null) { try { buffBanById.RemoveGroup(group); string str = string.Join(",", buffBanById.AllowedGroups); IDbConnection dbConnection = this.database; object[] objArray = new object[] { str, id }; if (DbExt.Query(dbConnection, "UPDATE BuffBans SET AllowedGroups=@0 WHERE BuffID=@1", objArray) <= 0) { return(false); } else { flag = true; } } catch (Exception exception) { TShock.Log.Error(exception.ToString()); return(false); } return(flag); } return(false); }
public bool BuffIsBanned(int id, TSPlayer ply) { BuffBan buffBanById = Koishi.BanBuff.Utils.GetBuffBanById(id); if (buffBanById == null) { return(false); } return(!buffBanById.HasPermissionToUseBuff(ply)); }
public void UpdateBuffBans() { this.BuffBans.Clear(); using (QueryResult queryResult = DbExt.QueryReader(this.database, "SELECT * FROM BuffBans", new object[0])) { while (queryResult != null && queryResult.Read()) { BuffBan buffBan = new BuffBan(queryResult.Get <int>("BuffID")); buffBan.SetAllowedGroups(queryResult.Get <string>("AllowedGroups")); this.BuffBans.Add(buffBan); } } }