Fixed GM loading world data files twice at startup.

Improved error reporting for invalid groups.yml
This commit is contained in:
ElgarL 2011-10-31 02:06:25 +00:00
parent 4ac03ef15a
commit b1c6173995
3 changed files with 35 additions and 26 deletions

View file

@ -53,4 +53,6 @@ v 1.5:
- Fixed opOverrides and bukkit_perms_override to read the correct entries. - Fixed opOverrides and bukkit_perms_override to read the correct entries.
- Better commenting in config.yml - Better commenting in config.yml
- Fixed GM to recognize Superperm child nodes. - Fixed GM to recognize Superperm child nodes.
If you add a node like Towny.admin GM will now correctly report on all child nodes. If you add a node like Towny.admin GM will now correctly report on all child nodes.
- Fixed GM loading world data files twice at startup.
- Improved error reporting for invalid groups.yml

View file

@ -483,7 +483,7 @@ public class WorldDataHolder {
//PROCESS GROUPS FILE //PROCESS GROUPS FILE
Map<String, List<String>> inheritance = new HashMap<String, List<String>>(); Map<String, List<String>> inheritance = new HashMap<String, List<String>>();
try { //try {
Map<String, Object> allGroupsNode = (Map<String, Object>) groupsRootDataNode.get("groups"); Map<String, Object> allGroupsNode = (Map<String, Object>) groupsRootDataNode.get("groups");
for (String groupKey : allGroupsNode.keySet()) { for (String groupKey : allGroupsNode.keySet()) {
Map<String, Object> thisGroupNode = (Map<String, Object>) allGroupsNode.get(groupKey); Map<String, Object> thisGroupNode = (Map<String, Object>) allGroupsNode.get(groupKey);
@ -513,36 +513,43 @@ public class WorldDataHolder {
} else if (thisGroupNode.get("permissions") instanceof String) { } else if (thisGroupNode.get("permissions") instanceof String) {
thisGrp.addPermission((String) thisGroupNode.get("permissions")); thisGrp.addPermission((String) thisGroupNode.get("permissions"));
} else { } else {
throw new IllegalArgumentException("Unknown type of permissions node(Should be String or List<String>): " + thisGroupNode.get("permissions").getClass().getName()); throw new IllegalArgumentException("Unknown type of permissions node(Should be String or List<String>) for group: " + thisGrp.getName());
} }
//INFO NODE //INFO NODE
Map<String, Object> infoNode = (Map<String, Object>) thisGroupNode.get("info"); if (thisGroupNode.get("info") instanceof Map) {
if (infoNode != null) { Map<String, Object> infoNode = (Map<String, Object>) thisGroupNode.get("info");
thisGrp.setVariables(infoNode); if (infoNode != null) {
} thisGrp.setVariables(infoNode);
}
} else
throw new IllegalArgumentException("Unknown entry found in Info section for group: " + thisGrp.getName());
//END INFO NODE //END INFO NODE
Object inheritNode = thisGroupNode.get("inheritance"); if (thisGroupNode.get("inheritance") == null || thisGroupNode.get("inheritance") instanceof List) {
if (inheritNode == null) { Object inheritNode = thisGroupNode.get("inheritance");
thisGroupNode.put("inheritance", new ArrayList<String>()); if (inheritNode == null) {
} else if (inheritNode instanceof List) { thisGroupNode.put("inheritance", new ArrayList<String>());
List<String> groupsInh = (List<String>) inheritNode; } else if (inheritNode instanceof List) {
for (String grp : groupsInh) { List<String> groupsInh = (List<String>) inheritNode;
if (inheritance.get(groupKey) == null) { for (String grp : groupsInh) {
List<String> thisInherits = new ArrayList<String>(); if (inheritance.get(groupKey) == null) {
inheritance.put(groupKey, thisInherits); List<String> thisInherits = new ArrayList<String>();
} inheritance.put(groupKey, thisInherits);
inheritance.get(groupKey).add(grp); }
inheritance.get(groupKey).add(grp);
}
} }
}
}else
throw new IllegalArgumentException("Unknown entry found in inheritance section for group: " + thisGrp.getName());
} }
} catch (Exception ex) { //} catch (Exception ex) {
ex.printStackTrace(); // ex.printStackTrace();
throw new IllegalArgumentException("Your Permissions config file is invalid. See console for details."); // throw new IllegalArgumentException("Your Permissions config file is invalid. See console for details.");
} //}
if (ph.defaultGroup == null) { if (ph.defaultGroup == null) {
throw new IllegalArgumentException("There was no Default Group declared."); throw new IllegalArgumentException("There was no Default Group declared.");
} }

View file

@ -100,7 +100,7 @@ public class WorldsHolder {
* or mirrored worlds that don't need data. * or mirrored worlds that don't need data.
*/ */
if (!worldsData.containsKey(folder.getName().toLowerCase()) if (!worldsData.containsKey(folder.getName().toLowerCase())
|| !mirrors.containsKey(folder.getName().toLowerCase())) { && !mirrors.containsKey(folder.getName().toLowerCase())) {
loadWorld(folder.getName()); loadWorld(folder.getName());
} }