diff options
Diffstat (limited to 'EssentialsGroupManager/src/org/anjocaido')
3 files changed, 36 insertions, 9 deletions
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java index e580918e7..c05065f5e 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java @@ -76,8 +76,13 @@ public class Group extends DataUnit implements Cloneable { if (dataSource.groupExists(this.getName())) { return null; } - Group clone = getDataSource().createGroup(this.getName()); - clone.inherits = new ArrayList<String>(this.getInherits()); + + Group clone = dataSource.createGroup(this.getName()); + + // Don't add inheritance for GlobalGroups + if (getDataSource() != null) { + clone.inherits = new ArrayList<String>(this.getInherits()); + } for (String perm : this.getPermissionList()) { clone.addPermission(perm); } diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java index 8cfb3d14a..6c4cdbcf2 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java @@ -67,7 +67,7 @@ public class User extends DataUnit implements Cloneable { if (dataSource.getGroup(group) == null) { clone.setGroup(dataSource.getDefaultGroup()); } else { - clone.setGroup(this.getGroupName()); + clone.setGroup(dataSource.getGroup(this.getGroupName())); } for (String perm : this.getPermissionList()) { clone.addPermission(perm); diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java index 1d07cdbe2..ce1693fc4 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java @@ -38,7 +38,7 @@ import org.yaml.snakeyaml.reader.UnicodeReader; public class WorldDataHolder { /** - * + * World name */ protected String name; /** @@ -321,32 +321,54 @@ public class WorldDataHolder { } } + /** + * Refresh Group data from file + */ public void reloadGroups() { GroupManager.setLoaded(false); try { // temporary holder in case the load fails. WorldDataHolder ph = new WorldDataHolder(this.getName()); + loadGroups(ph, getGroupsFile()); - this.groups = ph.getGroups(); + // transfer new data + resetGroups(); + for (Group tempGroup : ph.getGroupList()) { + if (tempGroup.getDataSource() != null) tempGroup.clone(this); + } + this.setDefaultGroup(this.getGroup(ph.getDefaultGroup().getName())); this.removeGroupsChangedFlag(); this.timeStampGroups = ph.getTimeStampGroups(); } catch (Exception ex) { - Logger.getLogger(WorldDataHolder.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(WorldDataHolder.class.getName()).log(Level.WARNING, null, ex); } GroupManager.setLoaded(true); } + /** + * Refresh Users data from file + */ public void reloadUsers() { GroupManager.setLoaded(false); try { // temporary holder in case the load fails. WorldDataHolder ph = new WorldDataHolder(this.getName()); + // copy groups for reference + for (Group tempGroup : this.getGroupList()) { + if (tempGroup.getDataSource() != null) tempGroup.clone(ph); + } + // setup the default group before loading user data. + ph.setDefaultGroup(ph.getGroup(this.getDefaultGroup().getName())); loadUsers(ph, getUsersFile()); - this.users = ph.getUsers(); + // transfer new data + resetUsers(); + for (User tempUser : ph.getUserList()) { + tempUser.clone(this); + } this.removeUsersChangedFlag(); this.timeStampUsers = ph.getTimeStampUsers(); } catch (Exception ex) { - Logger.getLogger(WorldDataHolder.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(WorldDataHolder.class.getName()).log(Level.WARNING, null, ex); } GroupManager.setLoaded(true); } @@ -576,7 +598,7 @@ public class WorldDataHolder { } if ((Boolean.parseBoolean(thisGroupNode.get("default").toString()))) { if (ph.getDefaultGroup() != null) { - GroupManager.logger.warning("The group " + thisGrp.getName() + " is declaring be default where" + ph.getDefaultGroup().getName() + " already was."); + GroupManager.logger.warning("The group " + thisGrp.getName() + " is claiming to be default where" + ph.getDefaultGroup().getName() + " already was."); GroupManager.logger.warning("Overriding first request."); } ph.setDefaultGroup(thisGrp); |