deleting the contents of GlobalGroups.yml will no longer thrown a

NullPointerException.
This commit is contained in:
ElgarL 2011-12-14 04:26:02 +00:00
parent 559400c606
commit 8d29a2c578
2 changed files with 47 additions and 42 deletions

View File

@ -84,4 +84,5 @@ v 1.7:
- GM now supports offline players without having to mantogglevalidate - GM now supports offline players without having to mantogglevalidate
- Offline player checks now support partial name matches. - Offline player checks now support partial name matches.
- Added custom events so plugins can now be notified of changes within GroupManager. - Added custom events so plugins can now be notified of changes within GroupManager.
- GM now registers with Bukkits ServicesManager. - GM now registers with Bukkits ServicesManager.
- deleting the contents of GlobalGroups.yml will no longer thrown a NullPointerException.

View File

@ -107,49 +107,53 @@ public class GlobalGroups {
throw new IllegalArgumentException("The following file couldn't pass on Parser.\n" + GlobalGroupsFile.getPath(), ex); throw new IllegalArgumentException("The following file couldn't pass on Parser.\n" + GlobalGroupsFile.getPath(), ex);
} }
// Read all global groups // Clear out old groups
Map<String, Object> allGroups = (Map<String, Object>) GGroups.getConfigurationSection("groups").getValues(false); resetGlobalGroups();
// Load each groups permissions list. if (!GGroups.getKeys(false).isEmpty()) {
if (allGroups != null) { // Read all global groups
// Clear out old groups Map<String, Object> allGroups = (Map<String, Object>) GGroups.getConfigurationSection("groups").getValues(false);
resetGlobalGroups();
for (String groupName : allGroups.keySet()) { // Load each groups permissions list.
Group newGroup = new Group(groupName.toLowerCase()); if (allGroups != null) {
Object element; for (String groupName : allGroups.keySet()) {
Group newGroup = new Group(groupName.toLowerCase());
// Permission nodes Object element;
element = GGroups.get("groups." + groupName + ".permissions");
// Permission nodes
if (element != null) element = GGroups.get("groups." + groupName + ".permissions");
if (element instanceof List) {
for (String node : (List<String>) element) { if (element != null)
newGroup.addPermission(node); if (element instanceof List) {
} for (String node : (List<String>) element) {
} else if (element instanceof String) { newGroup.addPermission(node);
newGroup.addPermission((String) element); }
} else } else if (element instanceof String) {
throw new IllegalArgumentException("Unknown type of permission node for global group: " + groupName); newGroup.addPermission((String) element);
} else
// Info nodes throw new IllegalArgumentException("Unknown type of permission node for global group: " + groupName);
element = GGroups.get("groups." + groupName + ".info");
// Info nodes
if (element != null) element = GGroups.get("groups." + groupName + ".info");
if (element instanceof MemorySection) {
Map<String, Object> vars = new HashMap<String, Object>(); if (element != null)
for (String key : ((MemorySection) element).getKeys(false)) { if (element instanceof MemorySection) {
vars.put(key, ((MemorySection) element).get(key)); Map<String, Object> vars = new HashMap<String, Object>();
} for (String key : ((MemorySection) element).getKeys(false)) {
newGroup.setVariables(vars); vars.put(key, ((MemorySection) element).get(key));
} else }
throw new IllegalArgumentException("Unknown type of info node for global group: " + groupName); newGroup.setVariables(vars);
} else
// Push a new group throw new IllegalArgumentException("Unknown type of info node for global group: " + groupName);
addGroup(newGroup);
// Push a new group
addGroup(newGroup);
}
} }
removeGroupsChangedFlag();
} }
removeGroupsChangedFlag();
setTimeStampGroups(GlobalGroupsFile.lastModified()); setTimeStampGroups(GlobalGroupsFile.lastModified());
GroupManager.setLoaded(true); GroupManager.setLoaded(true);
//GlobalGroupsFile = null; //GlobalGroupsFile = null;