/** * @param generatorUri the generator Uri * @param configs the new config params for the world generator */ public void setModuleConfigs(SimpleUri generatorUri, Map<String, Component> configs) { Gson gson = createGsonForModules(); Map<String, JsonElement> map = Maps.newHashMap(); for (Map.Entry<String, Component> entry : configs.entrySet()) { JsonElement json = gson.toJsonTree(entry.getValue()); map.put(entry.getKey(), json); } config.getModuleConfigs().put(generatorUri, map); }
/** * @param uri the uri to look up * @param key the look-up key * @param clazz the class to convert the data to * @return a config component for the given uri and class or <code>null</code> */ public <T extends Component> T getModuleConfig(SimpleUri uri, String key, Class<T> clazz) { Map<String, JsonElement> map = config.getModuleConfigs().get(uri); if (map == null) { return null; } JsonElement element = map.get(key); Gson gson = createGsonForModules(); return gson.fromJson(element, clazz); }