From b1c6173995721831c88570dd32edc77c369dca7a Mon Sep 17 00:00:00 2001 From: ElgarL Date: Mon, 31 Oct 2011 02:06:25 +0000 Subject: Fixed GM loading world data files twice at startup. Improved error reporting for invalid groups.yml --- .../groupmanager/dataholder/WorldDataHolder.java | 57 ++++++++++++---------- 1 file changed, 32 insertions(+), 25 deletions(-) (limited to 'EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java') diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java index 4a9f806d8..c8dc8cbd1 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java @@ -483,7 +483,7 @@ public class WorldDataHolder { //PROCESS GROUPS FILE Map> inheritance = new HashMap>(); - try { + //try { Map allGroupsNode = (Map) groupsRootDataNode.get("groups"); for (String groupKey : allGroupsNode.keySet()) { Map thisGroupNode = (Map) allGroupsNode.get(groupKey); @@ -513,36 +513,43 @@ public class WorldDataHolder { } else if (thisGroupNode.get("permissions") instanceof String) { thisGrp.addPermission((String) thisGroupNode.get("permissions")); } else { - throw new IllegalArgumentException("Unknown type of permissions node(Should be String or List): " + thisGroupNode.get("permissions").getClass().getName()); + throw new IllegalArgumentException("Unknown type of permissions node(Should be String or List) for group: " + thisGrp.getName()); } //INFO NODE - Map infoNode = (Map) thisGroupNode.get("info"); - if (infoNode != null) { - thisGrp.setVariables(infoNode); - } + if (thisGroupNode.get("info") instanceof Map) { + Map infoNode = (Map) thisGroupNode.get("info"); + if (infoNode != null) { + thisGrp.setVariables(infoNode); + } + } else + throw new IllegalArgumentException("Unknown entry found in Info section for group: " + thisGrp.getName()); + //END INFO NODE - Object inheritNode = thisGroupNode.get("inheritance"); - if (inheritNode == null) { - thisGroupNode.put("inheritance", new ArrayList()); - } else if (inheritNode instanceof List) { - List groupsInh = (List) inheritNode; - for (String grp : groupsInh) { - if (inheritance.get(groupKey) == null) { - List thisInherits = new ArrayList(); - inheritance.put(groupKey, thisInherits); - } - inheritance.get(groupKey).add(grp); - - } - } - } - } catch (Exception ex) { - ex.printStackTrace(); - throw new IllegalArgumentException("Your Permissions config file is invalid. See console for details."); - } + if (thisGroupNode.get("inheritance") == null || thisGroupNode.get("inheritance") instanceof List) { + Object inheritNode = thisGroupNode.get("inheritance"); + if (inheritNode == null) { + thisGroupNode.put("inheritance", new ArrayList()); + } else if (inheritNode instanceof List) { + List groupsInh = (List) inheritNode; + for (String grp : groupsInh) { + if (inheritance.get(groupKey) == null) { + List thisInherits = new ArrayList(); + inheritance.put(groupKey, thisInherits); + } + inheritance.get(groupKey).add(grp); + + } + } + }else + throw new IllegalArgumentException("Unknown entry found in inheritance section for group: " + thisGrp.getName()); + } + //} catch (Exception ex) { + // ex.printStackTrace(); + // throw new IllegalArgumentException("Your Permissions config file is invalid. See console for details."); + //} if (ph.defaultGroup == null) { throw new IllegalArgumentException("There was no Default Group declared."); } -- cgit v1.2.3