summaryrefslogtreecommitdiffstats
path: root/EssentialsGroupManager
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2011-12-14 10:03:32 +0100
committersnowleo <schneeleo@gmail.com>2011-12-14 10:03:32 +0100
commit258a5b9868bbea1012bb17b928594cac58d1a733 (patch)
treee376069eb05c6412dd90fc62b92f944dde90afaf /EssentialsGroupManager
parentf251cd14bad0b578990661c429d8b00480159bad (diff)
parentc27785879023e47d6d3187a49ecbc21c7b32037f (diff)
downloadEssentials-258a5b9868bbea1012bb17b928594cac58d1a733.tar
Essentials-258a5b9868bbea1012bb17b928594cac58d1a733.tar.gz
Essentials-258a5b9868bbea1012bb17b928594cac58d1a733.tar.lz
Essentials-258a5b9868bbea1012bb17b928594cac58d1a733.tar.xz
Essentials-258a5b9868bbea1012bb17b928594cac58d1a733.zip
Merge branch 'refs/heads/groupmanager'
Diffstat (limited to 'EssentialsGroupManager')
-rw-r--r--EssentialsGroupManager/src/Changelog.txt3
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/GlobalGroups.java86
2 files changed, 47 insertions, 42 deletions
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt
index b3a95d830..47a0f6b79 100644
--- a/EssentialsGroupManager/src/Changelog.txt
+++ b/EssentialsGroupManager/src/Changelog.txt
@@ -84,4 +84,5 @@ v 1.7:
- GM now supports offline players without having to mantogglevalidate
- Offline player checks now support partial name matches.
- Added custom events so plugins can now be notified of changes within GroupManager.
- - GM now registers with Bukkits ServicesManager. \ No newline at end of file
+ - GM now registers with Bukkits ServicesManager.
+ - deleting the contents of GlobalGroups.yml will no longer thrown a NullPointerException. \ 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 33b7b46f1..f1bf10985 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GlobalGroups.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GlobalGroups.java
@@ -107,49 +107,53 @@ public class GlobalGroups {
throw new IllegalArgumentException("The following file couldn't pass on Parser.\n" + GlobalGroupsFile.getPath(), ex);
}
- // Read all global groups
- Map<String, Object> allGroups = (Map<String, Object>) GGroups.getConfigurationSection("groups").getValues(false);
-
- // Load each groups permissions list.
- if (allGroups != null) {
- // Clear out old groups
- resetGlobalGroups();
- for (String groupName : allGroups.keySet()) {
- Group newGroup = new Group(groupName.toLowerCase());
- Object element;
-
- // Permission nodes
- element = GGroups.get("groups." + groupName + ".permissions");
-
- if (element != null)
- if (element instanceof List) {
- for (String node : (List<String>) element) {
- newGroup.addPermission(node);
- }
- } else if (element instanceof String) {
- newGroup.addPermission((String) element);
- } else
- throw new IllegalArgumentException("Unknown type of permission node for global group: " + groupName);
-
- // Info nodes
- element = GGroups.get("groups." + groupName + ".info");
-
- if (element != null)
- if (element instanceof MemorySection) {
- Map<String, Object> vars = new HashMap<String, Object>();
- for (String key : ((MemorySection) element).getKeys(false)) {
- vars.put(key, ((MemorySection) element).get(key));
- }
- newGroup.setVariables(vars);
- } else
- throw new IllegalArgumentException("Unknown type of info node for global group: " + groupName);
-
- // Push a new group
- addGroup(newGroup);
+ // Clear out old groups
+ resetGlobalGroups();
+
+ if (!GGroups.getKeys(false).isEmpty()) {
+ // Read all global groups
+ Map<String, Object> allGroups = (Map<String, Object>) GGroups.getConfigurationSection("groups").getValues(false);
+
+ // Load each groups permissions list.
+ if (allGroups != null) {
+ for (String groupName : allGroups.keySet()) {
+ Group newGroup = new Group(groupName.toLowerCase());
+ Object element;
+
+ // Permission nodes
+ element = GGroups.get("groups." + groupName + ".permissions");
+
+ if (element != null)
+ if (element instanceof List) {
+ for (String node : (List<String>) element) {
+ newGroup.addPermission(node);
+ }
+ } else if (element instanceof String) {
+ newGroup.addPermission((String) element);
+ } else
+ throw new IllegalArgumentException("Unknown type of permission node for global group: " + groupName);
+
+ // Info nodes
+ element = GGroups.get("groups." + groupName + ".info");
+
+ if (element != null)
+ if (element instanceof MemorySection) {
+ Map<String, Object> vars = new HashMap<String, Object>();
+ for (String key : ((MemorySection) element).getKeys(false)) {
+ vars.put(key, ((MemorySection) element).get(key));
+ }
+ newGroup.setVariables(vars);
+ } else
+ throw new IllegalArgumentException("Unknown type of info node for global group: " + groupName);
+
+ // Push a new group
+ addGroup(newGroup);
+ }
}
+
+ removeGroupsChangedFlag();
}
-
- removeGroupsChangedFlag();
+
setTimeStampGroups(GlobalGroupsFile.lastModified());
GroupManager.setLoaded(true);
//GlobalGroupsFile = null;