public Map<String, String> getSetStringMap(String path, Map<String, String> defaultValues) throws InvalidConfigurationException { if (config.isConfigurationSection(path)) { ConfigurationSection section = config.getConfigurationSection(path); Map<String, Object> entries = section.getValues(false); Map<String, String> values = new HashMap<>(entries.size()); for (Map.Entry<String, Object> entry : entries.entrySet()) { Object obj = entry.getValue(); if (obj instanceof String) { values.put(entry.getKey(), (String) obj); } else if (obj instanceof Double || obj instanceof Integer || obj instanceof Boolean) { values.put(entry.getKey(), obj.toString()); } else { throw new InvalidConfigurationException("Object " + obj + " found in map " + path + " in file " + configFile.toAbsolutePath() + " is not an integerr"); } } return values; } else if (config.contains(path)) { throw new InvalidConfigurationException("Object " + config.get(path) + " found under " + path + " in file " + configFile + " is not a map"); } else { logger.log(Level.INFO, "Setting {0} to {1} in file {2}", new Object[]{path, defaultValues, configFile}); ConfigurationSection section = config.createSection(path); for (Map.Entry<String, String> entry : defaultValues.entrySet()) { section.set(entry.getKey(), entry.getValue()); } return defaultValues; } }
public ConfigurationSection getSetSection(String path, Map<String, String> defaultValues) throws InvalidConfigurationException { if (config.isConfigurationSection(path)) { return config.getConfigurationSection(path); } else if (config.contains(path)) { throw new InvalidConfigurationException("Object " + config.get(path) + " found under " + path + " in file " + configFile + " is not a configuration section"); } else { logger.log(Level.INFO, "Setting {0} to {1} in file {2}", new Object[]{path, defaultValues, configFile}); ConfigurationSection section = config.createSection(path); for (Map.Entry<String, String> entry : defaultValues.entrySet()) { section.set(entry.getKey(), entry.getValue()); } return section; } }
protected void describeParameters(CommandSender sender) { Collection<String> keys = parameters.getKeys(false); if (keys.size() == 0) { sender.sendMessage(ChatColor.GRAY + " (None)"); } for (String key : keys) { String value = null; if (parameters.isConfigurationSection(key)) { ConfigurationSection child = parameters.getConfigurationSection(key); value = "(" + child.getKeys(false).size() + " values)"; } else { value = parameters.getString(key); } sender.sendMessage(ChatColor.LIGHT_PURPLE + " " + key + ": " + value); } }
addon.setDescription(asDescription(data)); if (data.isConfigurationSection("permissions")) { ConfigurationSection perms = data.getConfigurationSection("permissions"); perms.getKeys(true).forEach(perm -> {
if (config.isConfigurationSection(key)) { SkyKit kit; try {
if (cfg.isConfigurationSection("spawner")) { spawner = cfg.getConfigurationSection("spawner").getValues(false);
if (cfg.isConfigurationSection("spawner")) { spawner = cfg.getConfigurationSection("spawner").getValues(false);