Merge pull request #654 from PhoenixICE/general-devel

ItemBan Use Group Parenting
This commit is contained in:
k0rd 2013-10-11 09:56:22 -07:00
commit c112f433c5

View file

@ -196,13 +196,28 @@ namespace TShockAPI.DB
return Name == other.Name;
}
public bool HasPermissionToUseItem(TSPlayer ply)
{
if (ply == null)
return false;
return AllowedGroups.Contains(ply.Group.Name);
// could add in the other permissions in this class instead of a giant if switch.
}
public bool HasPermissionToUseItem(TSPlayer ply)
{
if (ply == null)
return false;
var cur = ply.Group;
var traversed = new List<Group>();
while (cur != null)
{
if (AllowedGroups.Contains(cur.Name))
{
return true;
}
if (traversed.Contains(cur))
{
throw new InvalidOperationException("Infinite group parenting ({0})".SFormat(cur.Name));
}
traversed.Add(cur);
cur = cur.Parent;
}
return false;
// could add in the other permissions in this class instead of a giant if switch.
}
public void SetAllowedGroups(String groups)
{