diff --git a/src/net/crystalyx/bukkit/simplyperms/SimplyPlugin.java b/src/net/crystalyx/bukkit/simplyperms/SimplyPlugin.java index 867a49b..64c9388 100755 --- a/src/net/crystalyx/bukkit/simplyperms/SimplyPlugin.java +++ b/src/net/crystalyx/bukkit/simplyperms/SimplyPlugin.java @@ -7,7 +7,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.Set; import net.crystalyx.bukkit.simplyperms.io.ConfigFile; import net.crystalyx.bukkit.simplyperms.io.ConfigSQL; @@ -119,6 +118,15 @@ public class SimplyPlugin extends JavaPlugin { return new SimplyAPI(this); } + public List getKeys(YamlConfiguration config, String node) { + if (config.isConfigurationSection(node)) { + return new ArrayList(config.getConfigurationSection(node).getKeys(false)); + } + else { + return new ArrayList(); + } + } + // -- Plugin stuff protected void registerPlayer(Player player) { @@ -171,49 +179,12 @@ public class SimplyPlugin extends JavaPlugin { return null; } - protected HashMap getAllPerms(String desc, String path) { - HashMap result = new HashMap(); - ConfigurationSection node = getNode(path); - - int failures = 0; - String firstFailure = ""; - - Set keys = node.getKeys(false); - for (String key : keys) { - if (node.isBoolean(key)) { - result.put(key, node.getBoolean(key)); - } else { - ++failures; - if (firstFailure.length() == 0) { - firstFailure = key; - } - } - } - - if (failures == 1) { - getLogger().warning("In " + desc + ": " + firstFailure + " is non-boolean."); - } else if (failures > 1) { - getLogger().warning("In " + desc + ": " + firstFailure + " is non-boolean (+" + (failures-1) + " more)."); - } - - return result; - } - public void debug(String message) { if (getConfig().getBoolean("debug", false)) { getLogger().info("Debug: " + message); } } - public List getKeys(YamlConfiguration config, String node) { - if (config.isConfigurationSection(node)) { - return new ArrayList(config.getConfigurationSection(node).getKeys(false)); - } - else { - return new ArrayList(); - } - } - protected void calculateAttachment(Player player) { if (player == null) { return; @@ -272,15 +243,15 @@ public class SimplyPlugin extends JavaPlugin { return new HashMap(); } - Map perms = getNode("groups/" + group + "/permissions") == null ? - new HashMap() : - getAllPerms("group " + group, "groups/" + group + "/permissions"); - + Map perms = new HashMap(); + for (String key : getNode("groups/" + group + "/permissions").getKeys(false)) { + perms.put(key, getNode("groups/" + group + "/permissions").getBoolean(key)); + } if (getNode("groups/" + group + "/worlds/" + world) != null) { - for (Map.Entry entry : getAllPerms("group " + group, "groups/" + group + "/worlds/" + world).entrySet()) { + for (String entry : getNode("groups/" + group + "/worlds/" + world).getKeys(false)) { // No containskey; world overrides non-world - perms.put(entry.getKey(), entry.getValue()); + perms.put(entry, getNode("groups/" + group + "/worlds/" + world).getBoolean(entry)); } }