@Override public String convertToString(Name value) { return value.toString(); } }
@Override public String getAsString(Name item) { if (item == null) { return ""; } return item.toString(); }
/** * Retrieves the matching entry for the given key. * @param id the id of the entry * @return the translated string */ public String lookup(Name id) { return dictionary.get(id.toString()); }
@Override public String getString(ResourceUrn value) { return value.getResourceName().toString(); } });
@Override public String getString(ResourceUrn value) { return value.getResourceName().toString(); } });
private String getString(DependencyInfo value) { if (value != null) { return value.getId().toString(); } return ""; }
@Override public Set<Name> getModulesProviding(Name resourceName) { Set<Name> result = Sets.newLinkedHashSet(); assetManager.resolve(resourceName.toString(), BlockTile.class).stream() .map(urn -> assetManager.getAsset(urn, BlockTile.class).get()) .filter(BlockTile::isAutoBlock) .forEach(tile -> result.add(tile.getUrn().getModuleName())); return result; }
private Path getPathForFlexibleConfig(SimpleUri flexibleConfigId) { Path filePath = PathManager.getInstance() .getConfigsPath() .resolve(flexibleConfigId.getModuleName().toString()) .resolve(flexibleConfigId.getObjectName().toString() + ".cfg"); // This call ensures that the entire directory structure (like configs/engine/) exists. ensureDirectoryExists(filePath); return filePath; } }
public byte getConnections(BlockUri blockUri) { if (getURI().equals(blockUri.getFamilyUri())) { try { return Byte.parseByte(blockUri.getIdentifier().toString().toLowerCase(Locale.ENGLISH)); } catch (NumberFormatException e) { logger.error("can't find block with URI: {}", blockUri, e); } } return 0; }
@Override public Map<String, ?> createTelemetryFieldToValue() { updateModules(); telemetryFieldToValue = new HashMap(); for (Module module : modules) { telemetryFieldToValue.put(module.getId().toString(), module.getVersion().toString()); } return telemetryFieldToValue; }
@Override public Optional<MeshData> getAssetData(ResourceUrn urn) throws IOException { if (ICON_DISCRIMINATOR.equals(urn.getResourceName())) { ResourceUrn textureUrn = new ResourceUrn(urn.getModuleName().toString() + ResourceUrn.RESOURCE_SEPARATOR + urn.getFragmentName().toString()); Optional<TextureRegionAsset> textureRegionAsset = assetManager.getAsset(textureUrn, TextureRegionAsset.class); if (textureRegionAsset.isPresent() && !textureRegionAsset.get().getTexture().isDisposed()) { return Optional.of(IconMeshFactory.generateIconMeshData(textureRegionAsset.get())); } } return Optional.empty(); }
@Override public Block getBlockFor(BlockUri blockUri) { if (getURI().equals(blockUri.getFamilyUri())) { try { Side side = Side.valueOf(blockUri.getIdentifier().toString().toUpperCase(Locale.ENGLISH)); return blocks.get(side); } catch (IllegalArgumentException e) { return null; } } return null; }
@Override public Block constructTransformedBlock(BlockFamilyDefinition definition, BlockShape shape, Rotation rotation, BlockUri uri, BlockFamily blockFamily) { return constructCustomBlock(definition.getUrn().getResourceName().toString(), shape, rotation, definition.getData().getBaseSection(), uri, blockFamily); }
private void setWorldGenerators() { for (WorldSetupWrapper worldSetupWrapper : worldList) { if (worldSetupWrapper.getWorldGenerator() == null) { try { worldSetupWrapper.setWorldGenerator(WorldGeneratorManager.createWorldGenerator(findWorldByName(worldSetupWrapper.getWorldName().toString()).getWorldGeneratorInfo().getUri(), context, environment)); } catch (UnresolvedWorldGeneratorException e) { e.printStackTrace(); } } worldSetupWrapper.getWorldGenerator().setWorldSeed(createSeed(worldSetupWrapper.getWorldName().toString())); } }
@Override public void onOpened() { UIImage previewImage = find("preview", UIImage.class); previewImage.setImage(texture); UILabel subitle = find("subtitle", UILabel.class); subitle.setText(translationSystem.translate("${engine:menu#start-playing}") + " in " + targetWorld.getWorldName().toString()); }
@Test public void shouldRegisterCommandWithoutSenderAnnotation() { //see https://github.com/MovingBlocks/Terasology/issues/2679 systemUnderTest.register(new SystemWithCommandMissingSenderAnnotation()); systemUnderTest.initialise(); ArgumentCaptor<MethodCommand> methodCommandArgumentCaptor = ArgumentCaptor.forClass(MethodCommand.class); verify(console).registerCommand(methodCommandArgumentCaptor.capture()); MethodCommand command = methodCommandArgumentCaptor.getValue(); assertThat(command.getName().toString(), is("commandWithoutSenderAnnotation")); }
private String getGeneralInfo(final GameInfo gameInfo) { return translationSystem.translate("${engine:menu#game-details-game-title} ") + gameInfo.getManifest().getTitle() + '\n' + '\n' + translationSystem.translate("${engine:menu#game-details-last-play}: ") + dateFormat.format(gameInfo.getTimestamp()) + '\n' + '\n' + translationSystem.translate("${engine:menu#game-details-game-duration} ") + DateTimeHelper .getDeltaBetweenTimestamps(new Date(0).getTime(), gameInfo.getManifest().getTime()) + '\n' + '\n' + translationSystem.translate("${engine:menu#game-details-game-seed} ") + gameInfo.getManifest().getSeed() + '\n' + '\n' + translationSystem.translate("${engine:menu#game-details-world-generator}: ") + '\t' + gameInfo.getManifest().getWorldInfo(TerasologyConstants.MAIN_WORLD).getWorldGenerator().getObjectName().toString(); }
@Override public Block constructTransformedBlock(BlockFamilyDefinition definition, Rotation rotation, BlockUri uri, BlockFamily blockFamily) { BlockShape shape = definition.getData().getBaseSection().getShape(); if (shape == null) { shape = cubeShape; } return constructCustomBlock(definition.getUrn().getResourceName().toString(), shape, rotation, definition.getData().getBaseSection(), uri, blockFamily); }
@Override public Block constructTransformedBlock(BlockFamilyDefinition definition, String section, Rotation rotation, BlockUri uri, BlockFamily blockFamily) { BlockShape shape = definition.getData().getSection(section).getShape(); if (shape == null) { shape = cubeShape; } return constructCustomBlock(definition.getUrn().getResourceName().toString(), shape, rotation, definition.getData().getSection(section), uri, blockFamily); }
@Override public Block constructSimpleBlock(BlockFamilyDefinition definition, String section, BlockUri uri, BlockFamily blockFamily) { BlockShape shape = definition.getData().getSection(section).getShape(); if (shape == null) { shape = cubeShape; } return constructCustomBlock(definition.getUrn().getResourceName().toString(), shape, Rotation.none(), definition.getData().getSection(section), uri, blockFamily); }