Catch errors caused by bad indentation in yml's.

This commit is contained in:
ElgarL 2012-03-29 14:02:53 +01:00
parent 1ef8ab70d1
commit 9dbeb1407c
3 changed files with 219 additions and 206 deletions

View file

@ -156,3 +156,4 @@ v 1.9:
- Auto rename all case sensitive world folders to lower case (if possible).
- Update GlobalGroups.yml for new/changed Towny permission nodes.
- Stop attempting to push empty permissions when players edit the yml's incorrectly.
- Catch errors caused by bad indentation in yml's.

View file

@ -116,6 +116,7 @@ public class GlobalGroups {
// Load each groups permissions list.
if (allGroups != null) {
try {
for (String groupName : allGroups.keySet()) {
Group newGroup = new Group(groupName.toLowerCase());
Object element;
@ -153,6 +154,9 @@ public class GlobalGroups {
// Push a new group
addGroup(newGroup);
}
} catch (Exception e) {
throw new IllegalArgumentException("Invalid node type, or bad indentation in GlobalGroups! ");
}
}
removeGroupsChangedFlag();

View file

@ -460,6 +460,7 @@ public class WorldDataHolder {
Map<String, List<String>> inheritance = new HashMap<String, List<String>>();
try {
Map<String, Object> allGroupsNode = (Map<String, Object>) groupsRootDataNode.get("groups");
try {
for (String groupKey : allGroupsNode.keySet()) {
Map<String, Object> thisGroupNode = (Map<String, Object>) allGroupsNode.get(groupKey);
Group thisGrp = ph.createGroup(groupKey);
@ -547,6 +548,9 @@ public class WorldDataHolder {
throw new IllegalArgumentException("Invalid formatting found in inheritance section for group: " + thisGrp.getName() + " in file: " + groupsFile.getPath());
}
}
} catch (Exception e) {
throw new IllegalArgumentException("Invalid node type, or bad indentation in file: " + groupsFile.getPath());
}
} catch (Exception ex) {
ex.printStackTrace();
throw new IllegalArgumentException("Your " + groupsFile.getPath() + " file is invalid. See console for details.");
@ -609,6 +613,7 @@ public class WorldDataHolder {
// Load users if the file is NOT empty
if (allUsersNode != null)
try {
for (String usersKey : allUsersNode.keySet()) {
Map<String, Object> thisUserNode = null;
try {
@ -695,6 +700,9 @@ public class WorldDataHolder {
thisUser.setGroup(ph.getDefaultGroup());
}
}
} catch (Exception e) {
throw new IllegalArgumentException("Invalid node type, or bad indentation in file: " + usersFile.getPath());
}
ph.removeUsersChangedFlag();
// Update the LastModified time.