summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--EssentialsGroupManager/src/Changelog.txt3
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/GlobalGroups.java14
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java9
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java11
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java77
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java4
-rw-r--r--EssentialsGroupManager/src/users.yml6
7 files changed, 78 insertions, 46 deletions
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt
index 5262c7018..d71bc135a 100644
--- a/EssentialsGroupManager/src/Changelog.txt
+++ b/EssentialsGroupManager/src/Changelog.txt
@@ -69,4 +69,5 @@ v 1.5:
If the files have been altered (on disc) it will reload, so long as the in-memory data hasn't changed.
If the files on Disc have changed AND there have been changes to it's in-memory data it will show a warning.
You then MUST issue a '/mansave force' to overwrite the disc files, or a '/manload' to overwrite the memory data.
- - Fix for an error in checkFullUserPermission caused by players disconnecting mid perms update. \ No newline at end of file
+ - Fix for an error in checkFullUserPermission caused by players disconnecting mid perms update.
+ - Notification of being moved to the default group only happens if it's a demotion/promotion (not on join). \ No newline at end of file
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GlobalGroups.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GlobalGroups.java
index eef5ba59e..861c5e3d4 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GlobalGroups.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GlobalGroups.java
@@ -83,7 +83,6 @@ public class GlobalGroups {
public void load() {
GGroups = new YamlConfiguration();
- groups = new HashMap<String, Group>();
GroupManager.setLoaded(false);
@@ -110,7 +109,9 @@ public class GlobalGroups {
Map<String, Object> allGroups = (Map<String, Object>) GGroups.getConfigurationSection("groups").getValues(false);
// Load each groups permissions list.
- if (allGroups != null)
+ if (allGroups != null) {
+ // Clear out old groups
+ resetGlobalGroups();
for (String groupName : allGroups.keySet()) {
Group newGroup = new Group(groupName.toLowerCase());
Object element;
@@ -144,12 +145,12 @@ public class GlobalGroups {
// Push a new group
addGroup(newGroup);
}
+ }
removeGroupsChangedFlag();
setTimeStampGroups(GlobalGroupsFile.lastModified());
GroupManager.setLoaded(true);
//GlobalGroupsFile = null;
-
}
/**
@@ -352,6 +353,13 @@ public class GlobalGroups {
}
/**
+ * Resets GlobalGroups.
+ */
+ public void resetGlobalGroups() {
+ this.groups = new HashMap<String, Group>();
+ }
+
+ /**
*
* @return a collection of the groups
*/
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 bcfa8e01b..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);
@@ -117,13 +117,20 @@ public class User extends DataUnit implements Cloneable {
getDataSource().addGroup(group);
}
group = getDataSource().getGroup(group.getName());
+ String oldGroup = this.group;
this.group = group.getName();
flagAsChanged();
if (GroupManager.isLoaded()) {
if (GroupManager.BukkitPermissions.player_join = false)
GroupManager.BukkitPermissions.updateAllPlayers();
+
+ // Do we notify of the group change?
+ String defaultGroupName = getDataSource().getDefaultGroup().getName();
+ // if we were not in the default group
+ // or we were in the default group and the move is to a different group.
+ boolean notify = (!oldGroup.equalsIgnoreCase(defaultGroupName)) || ((oldGroup.equalsIgnoreCase(defaultGroupName)) && (!this.group.equalsIgnoreCase(defaultGroupName))) ;
- GroupManager.notify(this.getName(), String.format(" moved to the group %s.", group.getName()));
+ if (notify) GroupManager.notify(this.getName(), String.format(" moved to the group %s.", group.getName()));
}
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java
index 4140cbfea..8f5fad5cf 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,24 +321,58 @@ public class WorldDataHolder {
}
}
+ /**
+ * Refresh Group data from file
+ */
public void reloadGroups() {
GroupManager.setLoaded(false);
try {
- resetGroups();
- loadGroups(this, getGroupsFile());
+ // temporary holder in case the load fails.
+ WorldDataHolder ph = new WorldDataHolder(this.getName());
+
+ loadGroups(ph, getGroupsFile());
+ // transfer new data
+ resetGroups();
+ for (Group tempGroup : ph.getGroupList()) {
+ tempGroup.clone(this);
+ }
+ this.setDefaultGroup(this.getGroup(ph.getDefaultGroup().getName()));
+ this.removeGroupsChangedFlag();
+ this.timeStampGroups = ph.getTimeStampGroups();
+
+ ph = null;
} 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 {
- resetUsers();
- loadUsers(this, getUsersFile());
+ // temporary holder in case the load fails.
+ WorldDataHolder ph = new WorldDataHolder(this.getName());
+ // copy groups for reference
+ for (Group tempGroup : this.getGroupList()) {
+ tempGroup.clone(ph);
+ }
+ // setup the default group before loading user data.
+ ph.setDefaultGroup(ph.getGroup(this.getDefaultGroup().getName()));
+ loadUsers(ph, getUsersFile());
+ // transfer new data
+ resetUsers();
+ for (User tempUser : ph.getUserList()) {
+ tempUser.clone(this);
+ }
+ this.removeUsersChangedFlag();
+ this.timeStampUsers = ph.getTimeStampUsers();
+
+ ph = null;
} 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);
}
@@ -524,29 +558,6 @@ public class WorldDataHolder {
}
/**
- * Updates the WorldDataHolder from the files
- *
- * @param ph
- * @param groupsFile
- * @param usersFile
- *
- * @throws FileNotFoundException
- * @throws IOException
- */
- public static WorldDataHolder Update(WorldDataHolder ph, File groupsFile, File usersFile) throws FileNotFoundException, IOException {
-
- GroupManager.setLoaded(false);
- ph.resetGroups();
- loadGroups(ph, groupsFile);
-
- ph.resetUsers();
- loadUsers(ph, usersFile);
- GroupManager.setLoaded(true);
-
- return ph;
- }
-
- /**
* Updates the WorldDataHolder from the Groups file
*
* @param ph
@@ -591,7 +602,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);
@@ -662,7 +673,7 @@ public class WorldDataHolder {
ph.removeGroupsChangedFlag();
// Update the LastModified time.
ph.groupsFile = groupsFile;
- ph.setTimeStamps();
+ ph.setTimeStampGroups(groupsFile.lastModified());
//return ph;
}
@@ -769,7 +780,7 @@ public class WorldDataHolder {
ph.removeUsersChangedFlag();
// Update the LastModified time.
ph.usersFile = usersFile;
- ph.setTimeStamps();
+ ph.setTimeStampUsers(usersFile.lastModified());
//return ph;
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
index bf7b290ae..6544bb1cc 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
@@ -200,8 +200,8 @@ public class WorldsHolder {
//Check for newer file as no local changes.
if (w.getTimeStampGroups() < w.getGroupsFile().lastModified()) {
System.out.print("Newer Groups file found (Loading changes)!");
- // Backup Users file
- backupFile(w,false);
+ // Backup Groups file
+ backupFile(w,true);
w.reloadGroups();
}
}
diff --git a/EssentialsGroupManager/src/users.yml b/EssentialsGroupManager/src/users.yml
index 43d030e9a..28fa79910 100644
--- a/EssentialsGroupManager/src/users.yml
+++ b/EssentialsGroupManager/src/users.yml
@@ -4,12 +4,12 @@ users:
subgroups: []
permissions: []
group: Admin
- mudzereli:
+ KHobbits:
subgroups: []
permissions: []
- group: Builder
+ group: Moderator
ElgarL:
subgroups: []
permissions: []
- group: Admin
+ group: Owner