use of org.terasology.gestalt.module.resources.EmptyFileSource in project Terasology by MovingBlocks.
the class ModuleDownloadListGeneratorTest method buildSimpleModule.
private Module buildSimpleModule(String id, String version) {
ModuleMetadata metadata = new ModuleMetadata();
metadata.setId(new Name(id));
if (version != null) {
metadata.setVersion(new Version(version));
}
return new Module(metadata, new EmptyFileSource(), Collections.emptyList(), new Reflections(), (c) -> false);
}
use of org.terasology.gestalt.module.resources.EmptyFileSource in project Terasology by MovingBlocks.
the class ModuleListDownloader method call.
@Override
public ModuleRegistry call() throws IOException {
logger.info("Downloading modules ..");
TableModuleRegistry modules = new TableModuleRegistry();
URL url = new URL("http", serverAddress, "/modules/list/latest");
try (InputStreamReader reader = new InputStreamReader(url.openStream(), TerasologyConstants.CHARSET)) {
logger.info("Parsing content ..");
JsonArray jsonArray = gson.fromJson(reader, JsonArray.class);
for (JsonElement jObject : jsonArray) {
String json = gson.toJson(jObject);
ModuleMetadata meta = metaReader.read(new StringReader(json));
logger.debug("Read module {} - {}", meta.getId(), meta.getVersion());
modules.add(new Module(meta, new EmptyFileSource(), Collections.emptyList(), new Reflections(), (c) -> false));
}
int count = modules.size();
logger.info(String.format("Retrieved %d %s", count, (count == 1) ? "entry" : "entries"));
}
return modules;
}
Aggregations