add commands for allowed groups for banned items
This commit is contained in:
parent
50eeae2a86
commit
2e7fa14a91
2 changed files with 135 additions and 20 deletions
|
|
@ -115,16 +115,23 @@ namespace TShockAPI.DB
|
|||
ItemBan b = GetItemBanByName(item);
|
||||
if (b != null)
|
||||
{
|
||||
groupsNew = String.Join(",", b.AllowedGroups);
|
||||
if (groupsNew.Length > 0)
|
||||
groupsNew += ",";
|
||||
groupsNew += name;
|
||||
b.SetAllowedGroups(groupsNew);
|
||||
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;
|
||||
int q = database.Query("UPDATE ItemBans SET AllowedGroups=@0 WHERE ItemName=@1", groupsNew,
|
||||
item);
|
||||
|
||||
return q > 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -135,12 +142,20 @@ namespace TShockAPI.DB
|
|||
ItemBan b = GetItemBanByName(item);
|
||||
if (b != null)
|
||||
{
|
||||
b.RemoveGroup(group);
|
||||
string groups = string.Join(",", b.AllowedGroups);
|
||||
int q = database.Query("UPDATE ItemBans SET AllowedGroups=@0 WHERE ItemName=@1", groups,
|
||||
item);
|
||||
if (q > 0)
|
||||
return true;
|
||||
try
|
||||
{
|
||||
b.RemoveGroup(group);
|
||||
string groups = string.Join(",", b.AllowedGroups);
|
||||
int q = database.Query("UPDATE ItemBans SET AllowedGroups=@0 WHERE ItemName=@1", groups,
|
||||
item);
|
||||
|
||||
if (q > 0)
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.ToString());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -212,7 +227,7 @@ namespace TShockAPI.DB
|
|||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
return Name + " (" + String.Join(",", AllowedGroups) + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue