Fix clones forgetting sub groups.

This commit is contained in:
ElgarL 2014-04-29 00:22:51 +01:00 committed by KHobbits
parent 211dc220d8
commit 86b57804c6
2 changed files with 16 additions and 1 deletions

View file

@ -228,4 +228,5 @@ v2.1:
- Update for CraftBukkit 1.7.8-R0.1(3050).
- Add UUID support.
Plugins can still query by player name but a UUID is faster and preferable.
- Set a default mirror map if none is found in the config.
- Set a default mirror map if none is found in the config.
- Fix clones forgetting sub groups.

View file

@ -53,6 +53,10 @@ public class User extends DataUnit implements Cloneable {
User clone = new User(getDataSource(), this.getLastName());
clone.group = this.group;
// Clone all subgroups.
clone.subGroups.addAll(this.subGroupListStringCopy());
for (String perm : this.getPermissionList()) {
clone.addPermission(perm);
}
@ -72,15 +76,22 @@ public class User extends DataUnit implements Cloneable {
if (dataSource.isUserDeclared(this.getUUID())) {
return null;
}
User clone = dataSource.createUser(this.getUUID());
if (dataSource.getGroup(group) == null) {
clone.setGroup(dataSource.getDefaultGroup());
} else {
clone.setGroup(dataSource.getGroup(this.getGroupName()));
}
// Clone all subgroups.
clone.subGroups.addAll(this.subGroupListStringCopy());
for (String perm : this.getPermissionList()) {
clone.addPermission(perm);
}
clone.variables = this.variables.clone(this);
clone.flagAsChanged();
return clone;
@ -95,6 +106,9 @@ public class User extends DataUnit implements Cloneable {
// Set the group silently.
clone.setGroup(this.getDataSource().getGroup(this.getGroupName()), false);
// Clone all subgroups.
clone.subGroups.addAll(this.subGroupListStringCopy());
for (String perm : this.getPermissionList()) {
clone.addPermission(perm);
}