Search in sources :

Example 1 with ModuleRegistry

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

the class HeadlessEnvironment method setupModuleManager.

@Override
protected void setupModuleManager(Set<Name> moduleNames) throws Exception {
    ModuleManager moduleManager = ModuleManagerFactory.create();
    ModuleRegistry registry = moduleManager.getRegistry();
    DependencyResolver resolver = new DependencyResolver(registry);
    ResolutionResult result = resolver.resolve(moduleNames);
    if (result.isSuccess()) {
        ModuleEnvironment modEnv = moduleManager.loadEnvironment(result.getModules(), true);
        logger.debug("Loaded modules: " + modEnv.getModuleIdsOrderedByDependencies());
    } else {
        logger.error("Could not resolve module dependencies for " + moduleNames);
    }
    context.put(ModuleManager.class, moduleManager);
    EntitySystemSetupUtil.addReflectionBasedLibraries(context);
}
Also used : ModuleEnvironment(org.terasology.module.ModuleEnvironment) ResolutionResult(org.terasology.module.ResolutionResult) ModuleRegistry(org.terasology.module.ModuleRegistry) ModuleManager(org.terasology.engine.module.ModuleManager) DependencyResolver(org.terasology.module.DependencyResolver)

Example 2 with ModuleRegistry

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

the class ModuleDownloadListGeneratorTest method testSingleModuleNoUpdate.

@Test
public void testSingleModuleNoUpdate() throws DependencyResolutionFailedException {
    ModuleRegistry localRegistry = buildRegistry("1.0.0", buildSimpleModule("myModule", "1.0.0"));
    DependencyResolver resolver = mockResolver(true, buildSimpleModule("myModule", "1.0.0"), buildEngineModule("1.0.0"));
    ModuleDownloadListGenerator listGenerator = new ModuleDownloadListGenerator(localRegistry, resolver);
    assertEquals(Collections.emptySet(), buildList(listGenerator));
}
Also used : TableModuleRegistry(org.terasology.module.TableModuleRegistry) ModuleRegistry(org.terasology.module.ModuleRegistry) DependencyResolver(org.terasology.module.DependencyResolver) Test(org.junit.Test)

Example 3 with ModuleRegistry

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

the class JoinGameScreen method getModulesText.

private String getModulesText(Future<ServerInfoMessage> info) {
    try {
        ServerInfoMessage serverInfoMessage = info.get();
        List<String> codedModInfo = new ArrayList<>();
        ModuleRegistry reg = moduleManager.getRegistry();
        for (NameVersion entry : serverInfoMessage.getModuleList()) {
            boolean isInstalled = reg.getModule(entry.getName(), entry.getVersion()) != null;
            Color color = isInstalled ? Color.GREEN : Color.RED;
            codedModInfo.add(FontColor.getColored(entry.toString(), color));
        }
        Collections.sort(codedModInfo, String.CASE_INSENSITIVE_ORDER);
        return Joiner.on('\n').join(codedModInfo);
    } catch (ExecutionException | InterruptedException e) {
        return FontColor.getColored(translationSystem.translate("${engine:menu#connection-failed}"), Color.RED);
    }
}
Also used : NameVersion(org.terasology.naming.NameVersion) FontColor(org.terasology.rendering.FontColor) Color(org.terasology.rendering.nui.Color) ArrayList(java.util.ArrayList) ModuleRegistry(org.terasology.module.ModuleRegistry) ServerInfoMessage(org.terasology.network.ServerInfoMessage) ExecutionException(java.util.concurrent.ExecutionException)

Example 4 with ModuleRegistry

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

the class ModuleDownloadListGeneratorTest method testResolverFailed.

@Test(expected = DependencyResolutionFailedException.class)
public void testResolverFailed() throws DependencyResolutionFailedException {
    ModuleRegistry localRegistry = buildRegistry("1.0.0", buildSimpleModule("myModule", "1.0.0"));
    DependencyResolver resolver = mockResolver(false);
    ModuleDownloadListGenerator listGenerator = new ModuleDownloadListGenerator(localRegistry, resolver);
    buildList(listGenerator);
}
Also used : TableModuleRegistry(org.terasology.module.TableModuleRegistry) ModuleRegistry(org.terasology.module.ModuleRegistry) DependencyResolver(org.terasology.module.DependencyResolver) Test(org.junit.Test)

Example 5 with ModuleRegistry

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

the class ModuleDownloadListGeneratorTest method testMultipleModulesPartialUpdate.

@Test
public void testMultipleModulesPartialUpdate() throws DependencyResolutionFailedException {
    Module moduleAV1 = buildSimpleModule("myModuleA", "1.0.0");
    Module moduleBV1 = buildSimpleModule("myModuleB", "1.0.0");
    Module moduleBV2 = buildSimpleModule("myModuleB", "2.0.0");
    ModuleRegistry localRegistry = buildRegistry("1.0.0", moduleAV1, moduleBV1);
    DependencyResolver resolver = mockResolver(true, moduleBV1, moduleBV2, buildEngineModule("1.0.0"));
    ModuleDownloadListGenerator listGenerator = new ModuleDownloadListGenerator(localRegistry, resolver);
    assertEquals(Collections.singleton(moduleBV2), buildList(listGenerator));
}
Also used : TableModuleRegistry(org.terasology.module.TableModuleRegistry) ModuleRegistry(org.terasology.module.ModuleRegistry) BaseModule(org.terasology.module.BaseModule) Module(org.terasology.module.Module) DependencyResolver(org.terasology.module.DependencyResolver) Test(org.junit.Test)

Aggregations

ModuleRegistry (org.terasology.module.ModuleRegistry)8 TableModuleRegistry (org.terasology.module.TableModuleRegistry)6 DependencyResolver (org.terasology.module.DependencyResolver)5 Test (org.junit.Test)4 Module (org.terasology.module.Module)3 ModuleManager (org.terasology.engine.module.ModuleManager)2 BaseModule (org.terasology.module.BaseModule)2 ModuleEnvironment (org.terasology.module.ModuleEnvironment)2 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1 RegisterBindAxis (org.terasology.input.RegisterBindAxis)1 RegisterBindButton (org.terasology.input.RegisterBindButton)1 ModuleMetadata (org.terasology.module.ModuleMetadata)1 ResolutionResult (org.terasology.module.ResolutionResult)1 Name (org.terasology.naming.Name)1 NameVersion (org.terasology.naming.NameVersion)1 Version (org.terasology.naming.Version)1 ServerInfoMessage (org.terasology.network.ServerInfoMessage)1 FontColor (org.terasology.rendering.FontColor)1 Color (org.terasology.rendering.nui.Color)1