-Improved group loading from the database:
--TShock will now attempt to load any available valid group data even if there are invalid records and will also report proper errors / warnings. --"superadmin" is now a reserved group name. --Groups with parents causing infinite parent loops, invaild parents, or parenting theirselfes will have their parent group reset. --Double definitions of groups with the same name are no longer allowed. --Group instances are now tried to be preserved instead of being recreated during a reload of the group data. -Added command "/group parent" to get and set the parent of groups. -REST Endpoint "/v2/groups/create" will no longer allow creating groups having theirselfes as parent. -REST Endpoint "/v2/groups/update" will no longer allow setting a group's parent to theirself or setting a parent group resulting in an infinite parent loop. -This commit should fix #482.
This commit is contained in:
parent
4e7b497ae4
commit
33091035c0
3 changed files with 202 additions and 64 deletions
|
|
@ -204,7 +204,7 @@ namespace TShockAPI
|
|||
return true;
|
||||
if (traversed.Contains(cur))
|
||||
{
|
||||
throw new Exception("Infinite group parenting ({0})".SFormat(cur.Name));
|
||||
throw new InvalidOperationException("Infinite group parenting ({0})".SFormat(cur.Name));
|
||||
}
|
||||
traversed.Add(cur);
|
||||
cur = cur.Parent;
|
||||
|
|
@ -270,6 +270,26 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
permissions.Remove(permission);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Assigns all fields of this instance to another.
|
||||
/// </summary>
|
||||
/// <param name="otherGroup">The other instance.</param>
|
||||
public void AssignTo(Group otherGroup)
|
||||
{
|
||||
otherGroup.Name = Name;
|
||||
otherGroup.Parent = Parent;
|
||||
otherGroup.Prefix = Prefix;
|
||||
otherGroup.Suffix = Suffix;
|
||||
otherGroup.R = R;
|
||||
otherGroup.G = G;
|
||||
otherGroup.B = B;
|
||||
otherGroup.Permissions = Permissions;
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return this.Name;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue