summaryrefslogtreecommitdiffstats
path: root/EssentialsGroupManager
diff options
context:
space:
mode:
authorElgarL <ElgarL@palmergames.com>2011-11-21 09:51:31 +0000
committerElgarL <ElgarL@palmergames.com>2011-11-21 09:51:31 +0000
commitfd1c2824ce0a0b5932ac009e706b371fe8a6072d (patch)
tree285f690dd0d61edae5200e0f358d82f90e8df116 /EssentialsGroupManager
parent000d060ea690ba14b665e01e9097e3885d796820 (diff)
downloadEssentials-fd1c2824ce0a0b5932ac009e706b371fe8a6072d.tar
Essentials-fd1c2824ce0a0b5932ac009e706b371fe8a6072d.tar.gz
Essentials-fd1c2824ce0a0b5932ac009e706b371fe8a6072d.tar.lz
Essentials-fd1c2824ce0a0b5932ac009e706b371fe8a6072d.tar.xz
Essentials-fd1c2824ce0a0b5932ac009e706b371fe8a6072d.zip
Stop throwing errors on an empty users file.
Diffstat (limited to 'EssentialsGroupManager')
-rw-r--r--EssentialsGroupManager/src/Changelog.txt3
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java130
2 files changed, 65 insertions, 68 deletions
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt
index d3d606079..580d8bc88 100644
--- a/EssentialsGroupManager/src/Changelog.txt
+++ b/EssentialsGroupManager/src/Changelog.txt
@@ -74,4 +74,5 @@ v 1.5:
- Fixed GM holding files open and causing the time stamp to be incorrect. This caused GM to require a '/mansave force' when it shouldn't be needed.
- Fixed a crash on reload due to bukkit not unloading plugins before reloading.
v 1.6:
- - Prevent Group.equals tests throwing a NullPointerException for GlobalGroups. \ No newline at end of file
+ - Prevent Group.equals tests throwing a NullPointerException for GlobalGroups.
+ - Stop throwing errors on an empty users file. \ No newline at end of file
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java
index 7dbeea7b1..683ba24a9 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java
@@ -711,78 +711,74 @@ public class WorldDataHolder {
// PROCESS USERS FILE
Map<String, Object> allUsersNode = (Map<String, Object>) usersRootDataNode.get("users");
- // Stop loading if the file is empty
- if (allUsersNode == null)
- return ;
-
- for (String usersKey : allUsersNode.keySet()) {
- Map<String, Object> thisUserNode = (Map<String, Object>) allUsersNode.get(usersKey);
- User thisUser = ph.createUser(usersKey);
- if (thisUser == null) {
- throw new IllegalArgumentException("I think this user was declared more than once: " + usersKey);
- }
- if (thisUserNode.get("permissions") == null) {
- thisUserNode.put("permissions", new ArrayList<String>());
- }
- if (thisUserNode.get("permissions") instanceof List) {
- for (Object o : ((List) thisUserNode.get("permissions"))) {
- thisUser.addPermission(o.toString());
- }
- } else if (thisUserNode.get("permissions") instanceof String) {
- thisUser.addPermission(thisUserNode.get("permissions").toString());
- }
-
- //SUBGROUPS LOADING
- if (thisUserNode.get("subgroups") == null) {
- thisUserNode.put("subgroups", new ArrayList<String>());
- }
- if (thisUserNode.get("subgroups") instanceof List) {
- for (Object o : ((List) thisUserNode.get("subgroups"))) {
- Group subGrp = ph.getGroup(o.toString());
- if (subGrp != null) {
- thisUser.addSubGroup(subGrp);
- } else {
- GroupManager.logger.warning("Subgroup " + o.toString() + " not found for user " + thisUser.getName() + ". Ignoring entry.");
- }
- }
- } else if (thisUserNode.get("subgroups") instanceof String) {
- Group subGrp = ph.getGroup(thisUserNode.get("subgroups").toString());
- if (subGrp != null) {
- thisUser.addSubGroup(subGrp);
- } else {
- GroupManager.logger.warning("Subgroup " + thisUserNode.get("subgroups").toString() + " not found for user " + thisUser.getName() + ". Ignoring entry.");
- }
- }
-
-
- //USER INFO NODE - BETA
-
- //INFO NODE
- Map<String, Object> infoNode = (Map<String, Object>) thisUserNode.get("info");
- if (infoNode != null) {
- thisUser.setVariables(infoNode);
- }
- //END INFO NODE - BETA
-
- if (thisUserNode.get("group") != null) {
- Group hisGroup = ph.getGroup(thisUserNode.get("group").toString());
- if (hisGroup == null) {
- GroupManager.logger.warning("There is no group " + thisUserNode.get("group").toString() + ", as stated for player " + thisUser.getName() + ": Set to '" + ph.getDefaultGroup().getName() + "'.");
- hisGroup = ph.defaultGroup;
- //throw new IllegalArgumentException("There is no group " + thisUserNode.get("group").toString() + ", as stated for player " + thisUser.getName());
- }
- thisUser.setGroup(hisGroup);
- } else {
- thisUser.setGroup(ph.defaultGroup);
- }
- }
+ // Load users if the file is NOT empty
+ if (allUsersNode != null)
+ for (String usersKey : allUsersNode.keySet()) {
+ Map<String, Object> thisUserNode = (Map<String, Object>) allUsersNode.get(usersKey);
+ User thisUser = ph.createUser(usersKey);
+ if (thisUser == null) {
+ throw new IllegalArgumentException("I think this user was declared more than once: " + usersKey);
+ }
+ if (thisUserNode.get("permissions") == null) {
+ thisUserNode.put("permissions", new ArrayList<String>());
+ }
+ if (thisUserNode.get("permissions") instanceof List) {
+ for (Object o : ((List) thisUserNode.get("permissions"))) {
+ thisUser.addPermission(o.toString());
+ }
+ } else if (thisUserNode.get("permissions") instanceof String) {
+ thisUser.addPermission(thisUserNode.get("permissions").toString());
+ }
+
+ //SUBGROUPS LOADING
+ if (thisUserNode.get("subgroups") == null) {
+ thisUserNode.put("subgroups", new ArrayList<String>());
+ }
+ if (thisUserNode.get("subgroups") instanceof List) {
+ for (Object o : ((List) thisUserNode.get("subgroups"))) {
+ Group subGrp = ph.getGroup(o.toString());
+ if (subGrp != null) {
+ thisUser.addSubGroup(subGrp);
+ } else {
+ GroupManager.logger.warning("Subgroup " + o.toString() + " not found for user " + thisUser.getName() + ". Ignoring entry.");
+ }
+ }
+ } else if (thisUserNode.get("subgroups") instanceof String) {
+ Group subGrp = ph.getGroup(thisUserNode.get("subgroups").toString());
+ if (subGrp != null) {
+ thisUser.addSubGroup(subGrp);
+ } else {
+ GroupManager.logger.warning("Subgroup " + thisUserNode.get("subgroups").toString() + " not found for user " + thisUser.getName() + ". Ignoring entry.");
+ }
+ }
+
+
+ //USER INFO NODE - BETA
+
+ //INFO NODE
+ Map<String, Object> infoNode = (Map<String, Object>) thisUserNode.get("info");
+ if (infoNode != null) {
+ thisUser.setVariables(infoNode);
+ }
+ //END INFO NODE - BETA
+
+ if (thisUserNode.get("group") != null) {
+ Group hisGroup = ph.getGroup(thisUserNode.get("group").toString());
+ if (hisGroup == null) {
+ GroupManager.logger.warning("There is no group " + thisUserNode.get("group").toString() + ", as stated for player " + thisUser.getName() + ": Set to '" + ph.getDefaultGroup().getName() + "'.");
+ hisGroup = ph.defaultGroup;
+ //throw new IllegalArgumentException("There is no group " + thisUserNode.get("group").toString() + ", as stated for player " + thisUser.getName());
+ }
+ thisUser.setGroup(hisGroup);
+ } else {
+ thisUser.setGroup(ph.defaultGroup);
+ }
+ }
ph.removeUsersChangedFlag();
// Update the LastModified time.
ph.usersFile = usersFile;
ph.setTimeStampUsers(usersFile.lastModified());
-
- //return ph;
}
/**