/** * Set paths. * @param config * @param addPaths */ public static void setPaths(final ConfigurationSection config, final Map<String, Object> setPaths, final boolean override) { setPaths(config, setPaths, "", override); }
/** * Recursive version supporting ConfigurationSection. * @param config * @param setPaths * @param pathPrefix */ protected static void setPaths(final ConfigurationSection config, final Map<String, Object> setPaths, final String pathPrefix, final boolean override) { for (final Entry<String, Object> entry : setPaths.entrySet()) { final String path = entry.getKey(); final Object value = entry.getValue(); if (value instanceof ConfigurationSection) { // Deep or not should not matter here. setPaths(config, ((ConfigurationSection) value).getValues(true), pathPrefix + path + ".", override); } else { if (override || !config.contains(path)) { config.set(pathPrefix + path, value); } } } }
setPaths(config, addPaths, false); changed = true;