package io.gitlab.jfronny.inceptum.install.steps; import io.gitlab.jfronny.inceptum.Inceptum; import io.gitlab.jfronny.inceptum.install.SetupStepInfo; import io.gitlab.jfronny.inceptum.install.Step; import io.gitlab.jfronny.inceptum.model.mojang.AssetIndex; import io.gitlab.jfronny.inceptum.util.McApi; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.Map; public class DownloadAssetsStep implements Step { @Override public void execute(SetupStepInfo info) throws IOException { Path o = Inceptum.ASSETS_DIR.resolve("objects"); for (Map.Entry entry : McApi.getAssetIndex(info.version()).objects.entrySet()) { Path fPath = o.resolve(entry.getValue().hash.substring(0, 2)); if (!Files.exists(fPath)) Files.createDirectories(fPath); fPath = fPath.resolve(entry.getValue().hash); if (Files.exists(fPath)) return; Inceptum.LOGGER.info("Downloading asset: " + entry.getKey()); McApi.downloadAsset(entry.getValue(), fPath); } } }