Search in sources :

Example 1 with TableModuleRegistry

use of org.terasology.module.TableModuleRegistry 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 (JsonReader reader = new JsonReader(new InputStreamReader(url.openStream(), TerasologyConstants.CHARSET))) {
        logger.info("Parsing content ..");
        reader.beginArray();
        while (reader.hasNext()) {
            ModuleMetadata meta = metaReader.read(reader);
            logger.debug("Read module {} - {}", meta.getId(), meta.getVersion());
            RemoteModule remoteModule = new RemoteModule(meta);
            modules.add(remoteModule);
        }
        reader.endArray();
        int count = modules.size();
        logger.info(String.format("Retrieved %d %s", count, (count == 1) ? "entry" : "entries"));
    }
    return modules;
}
Also used : InputStreamReader(java.io.InputStreamReader) TableModuleRegistry(org.terasology.module.TableModuleRegistry) ModuleMetadata(org.terasology.module.ModuleMetadata) JsonReader(com.google.gson.stream.JsonReader) URL(java.net.URL)

Example 2 with TableModuleRegistry

use of org.terasology.module.TableModuleRegistry in project Terasology by MovingBlocks.

the class ModuleDownloadListGeneratorTest method buildRegistry.

private ModuleRegistry buildRegistry(String engineVersion, Module... modules) {
    ModuleRegistry result = new TableModuleRegistry();
    result.add(buildEngineModule(engineVersion));
    result.addAll(Arrays.asList(modules));
    return result;
}
Also used : TableModuleRegistry(org.terasology.module.TableModuleRegistry) TableModuleRegistry(org.terasology.module.TableModuleRegistry) ModuleRegistry(org.terasology.module.ModuleRegistry)

Example 3 with TableModuleRegistry

use of org.terasology.module.TableModuleRegistry in project Terasology by MovingBlocks.

the class BindsSubsystemTest method setUpMockModuleEnvironment.

private void setUpMockModuleEnvironment() {
    ModuleManager moduleManager = mock(ModuleManager.class);
    ModuleRegistry moduleRegistry = new TableModuleRegistry();
    Module module = mock(Module.class);
    when(module.isCodeModule()).thenReturn(true);
    when(module.getId()).thenReturn(new Name(TEST_MODULE));
    when(module.getVersion()).thenReturn(new Version(0, 0, 1, true));
    when(module.getMetadata()).thenReturn(new ModuleMetadata());
    moduleRegistry.add(module);
    when(moduleManager.getRegistry()).thenReturn(moduleRegistry);
    ModuleEnvironment environment = mock(ModuleEnvironment.class);
    when(moduleManager.loadEnvironment(any(), anyBoolean())).thenReturn(environment);
    when(moduleManager.getEnvironment()).thenReturn(environment);
    registerBindButtonClasses = new ArrayList<>();
    when(environment.getTypesAnnotatedWith(eq(RegisterBindButton.class))).thenReturn(registerBindButtonClasses);
    when(environment.getTypesAnnotatedWith(eq(RegisterBindButton.class), any())).thenReturn(registerBindButtonClasses);
    registerRealBindAxisClasses = new ArrayList<>();
    when(environment.getTypesAnnotatedWith(eq(RegisterBindAxis.class))).thenReturn(registerRealBindAxisClasses);
    when(environment.getTypesAnnotatedWith(eq(RegisterBindAxis.class), any())).thenReturn(registerRealBindAxisClasses);
    when(environment.getModuleProviding(any())).thenReturn(new Name(TEST_MODULE));
    context.put(ModuleManager.class, moduleManager);
}
Also used : TableModuleRegistry(org.terasology.module.TableModuleRegistry) Version(org.terasology.naming.Version) ModuleEnvironment(org.terasology.module.ModuleEnvironment) RegisterBindButton(org.terasology.input.RegisterBindButton) RegisterBindAxis(org.terasology.input.RegisterBindAxis) ModuleRegistry(org.terasology.module.ModuleRegistry) TableModuleRegistry(org.terasology.module.TableModuleRegistry) ModuleMetadata(org.terasology.module.ModuleMetadata) ModuleManager(org.terasology.engine.module.ModuleManager) Module(org.terasology.module.Module) Name(org.terasology.naming.Name)

Aggregations

TableModuleRegistry (org.terasology.module.TableModuleRegistry)3 ModuleMetadata (org.terasology.module.ModuleMetadata)2 ModuleRegistry (org.terasology.module.ModuleRegistry)2 JsonReader (com.google.gson.stream.JsonReader)1 InputStreamReader (java.io.InputStreamReader)1 URL (java.net.URL)1 ModuleManager (org.terasology.engine.module.ModuleManager)1 RegisterBindAxis (org.terasology.input.RegisterBindAxis)1 RegisterBindButton (org.terasology.input.RegisterBindButton)1 Module (org.terasology.module.Module)1 ModuleEnvironment (org.terasology.module.ModuleEnvironment)1 Name (org.terasology.naming.Name)1 Version (org.terasology.naming.Version)1