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);
}
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));
}
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);
}
}
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);
}
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));
}
Aggregations