diff options
author | ElgarL <ElgarL@Palmergames.com> | 2014-04-29 00:22:51 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2014-05-04 12:50:22 +0100 |
commit | d46d8d45fa23e344901220d99e87cebc2352e689 (patch) | |
tree | 444347e37b76a7af7a28c847ec54fb70d5775aaa | |
parent | 89b759d7ac9092270dc229f9fb09f42b65f74f42 (diff) | |
download | Essentials-d46d8d45fa23e344901220d99e87cebc2352e689.tar Essentials-d46d8d45fa23e344901220d99e87cebc2352e689.tar.gz Essentials-d46d8d45fa23e344901220d99e87cebc2352e689.tar.lz Essentials-d46d8d45fa23e344901220d99e87cebc2352e689.tar.xz Essentials-d46d8d45fa23e344901220d99e87cebc2352e689.zip |
Fix clones forgetting sub groups.
-rw-r--r-- | EssentialsGroupManager/src/Changelog.txt | 3 | ||||
-rw-r--r-- | EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java | 14 |
2 files changed, 16 insertions, 1 deletions
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt index 583200e26..baf46b004 100644 --- a/EssentialsGroupManager/src/Changelog.txt +++ b/EssentialsGroupManager/src/Changelog.txt @@ -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.
\ No newline at end of file + - Set a default mirror map if none is found in the config.
+ - Fix clones forgetting sub groups.
\ No newline at end of file diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java index 38663ba7d..83e170137 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java @@ -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); } |