예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
 public void AddNewBan(int BuffID = 0)
 {
     try
     {
         IDbConnection dbConnection = this.database;
         object[]      buffID       = new object[] { BuffID, "" };
         DbExt.Query(dbConnection, "INSERT INTO BuffBans (BuffID, AllowedGroups) VALUES (@0, @1);", buffID);
         if (!this.BuffIsBanned(BuffID, null))
         {
             this.BuffBans.Add(new BuffBan(BuffID));
         }
     }
     catch (Exception exception)
     {
         TShock.Log.Error(exception.ToString());
     }
 }
예제 #4
0
 public void RemoveBan(int BuffID)
 {
     if (!this.BuffIsBanned(BuffID, null))
     {
         return;
     }
     try
     {
         IDbConnection dbConnection = this.database;
         object[]      buffID       = new object[] { BuffID };
         DbExt.Query(dbConnection, "DELETE FROM BuffBans WHERE BuffID=@0;", buffID);
         this.BuffBans.Remove(new BuffBan(BuffID));
     }
     catch (Exception exception)
     {
         TShock.Log.Error(exception.ToString());
     }
 }