Permission nodes

This commit is contained in:
MarioE 2012-08-19 20:47:30 -04:00
parent 0b02b90df0
commit e22f3e03c4

View file

@ -173,6 +173,19 @@ namespace TShockAPI
/// <param name="permission">The permission to check.</param>
/// <returns>Returns true if the user has that permission.</returns>
public virtual bool HasPermission(string permission)
{
string[] nodes = permission.Split('.');
for (int i = nodes.Length - 1; i >= 0; i--)
{
if (RealHasPermission(String.Join(".", nodes)))
{
return true;
}
nodes[i] = "*";
}
return false;
}
private bool RealHasPermission(string permission)
{
if (string.IsNullOrEmpty(permission))
return true;