Search in sources :

Example 1 with Modpack

use of net.technicpack.rest.io.Modpack in project LauncherV3 by TechnicPack.

the class CachedSolderPackApi method getPackBuild.

@Override
public Modpack getPackBuild(String build) throws BuildInaccessibleException {
    Boolean isDead = deadBuildCache.getIfPresent(build);
    if (isDead != null && isDead.booleanValue())
        return null;
    Modpack modpack = buildCache.getIfPresent(build);
    if (modpack != null) {
        return modpack;
    }
    try {
        modpack = innerApi.getPackBuild(build);
        if (modpack != null) {
            buildCache.put(build, modpack);
        }
        return modpack;
    } finally {
        deadBuildCache.put(build, modpack == null);
    }
}
Also used : Modpack(net.technicpack.rest.io.Modpack)

Example 2 with Modpack

use of net.technicpack.rest.io.Modpack in project LauncherV3 by TechnicPack.

the class HttpSolderPackApi method getPackBuild.

@Override
public Modpack getPackBuild(String build) throws BuildInaccessibleException {
    try {
        String url = baseUrl + "modpack/" + modpackSlug + "/" + build + "?cid=" + clientId;
        Modpack pack = RestObject.getRestObject(Modpack.class, url);
        if (pack != null) {
            return pack;
        }
    } catch (RestfulAPIException e) {
        throw new BuildInaccessibleException(modpackSlug, build, e);
    }
    throw new BuildInaccessibleException(modpackSlug, build);
}
Also used : RestfulAPIException(net.technicpack.rest.RestfulAPIException) Modpack(net.technicpack.rest.io.Modpack) BuildInaccessibleException(net.technicpack.launchercore.exception.BuildInaccessibleException)

Example 3 with Modpack

use of net.technicpack.rest.io.Modpack in project LauncherV3 by TechnicPack.

the class Installer method buildTasksQueue.

public void buildTasksQueue(InstallTasksQueue queue, ResourceLoader resources, ModpackModel modpack, String build, boolean doFullInstall, MojangVersionBuilder versionBuilder) throws CacheDeleteException, BuildInaccessibleException {
    PackInfo packInfo = modpack.getPackInfo();
    Modpack modpackData = packInfo.getModpack(build);
    if (modpackData.getGameVersion() == null)
        return;
    String minecraft = modpackData.getGameVersion();
    Version installedVersion = modpack.getInstalledVersion();
    TaskGroup examineModpackData = new TaskGroup(resources.getString("install.message.examiningmodpack"));
    TaskGroup verifyingFiles = new TaskGroup(resources.getString("install.message.verifyingfiles"));
    TaskGroup downloadingMods = new TaskGroup(resources.getString("install.message.downloadmods"));
    TaskGroup installingMods = new TaskGroup(resources.getString("install.message.installmods"));
    TaskGroup checkVersionFile = new TaskGroup(resources.getString("install.message.checkversionfile"));
    TaskGroup installVersionFile = new TaskGroup(resources.getString("install.message.installversionfile"));
    TaskGroup rundataTaskGroup = new TaskGroup(resources.getString("install.message.runData"));
    TaskGroup examineVersionFile = new TaskGroup(resources.getString("install.message.examiningversionfile"));
    TaskGroup grabLibs = new TaskGroup(resources.getString("install.message.grablibraries"));
    TaskGroup checkNonMavenLibs = new TaskGroup(resources.getString("install.message.nonmavenlibs"));
    TaskGroup installingLibs = new TaskGroup(resources.getString("install.message.installlibs"));
    TaskGroup installingMinecraft = new TaskGroup(resources.getString("install.message.installminecraft"));
    TaskGroup examineIndex = new TaskGroup(resources.getString("install.message.examiningindex"));
    TaskGroup verifyingAssets = new TaskGroup(resources.getString("install.message.verifyassets"));
    TaskGroup installingAssets = new TaskGroup(resources.getString("install.message.installassets"));
    TaskGroup examineJava = new TaskGroup("Examining Java runtime...");
    TaskGroup downloadJava = new TaskGroup("Downloading Java runtime...");
    queue.addTask(examineModpackData);
    queue.addTask(verifyingFiles);
    queue.addTask(downloadingMods);
    queue.addTask(installingMods);
    queue.addTask(checkVersionFile);
    queue.addTask(installVersionFile);
    queue.addTask(rundataTaskGroup);
    queue.addTask(examineVersionFile);
    queue.addTask(grabLibs);
    queue.addTask(checkNonMavenLibs);
    queue.addTask(installingLibs);
    queue.addTask(installingMinecraft);
    queue.addTask(examineIndex);
    queue.addTask(verifyingAssets);
    queue.addTask(installingAssets);
    queue.addTask(examineJava);
    queue.addTask(downloadJava);
    if (OperatingSystem.getOperatingSystem() == OperatingSystem.OSX)
        queue.addTask(new CopyDylibJnilibTask(modpack));
    // Add FML libs
    String fmlLibsZip;
    File modpackFmlLibDir = new File(modpack.getInstalledDirectory(), "lib");
    HashMap<String, String> fmlLibs = new HashMap<>();
    switch(minecraft) {
        case "1.4":
        case "1.4.1":
        case "1.4.2":
        case "1.4.3":
        case "1.4.4":
        case "1.4.5":
        case "1.4.6":
        case "1.4.7":
            fmlLibsZip = "fml_libs.zip";
            break;
        case "1.5":
            fmlLibsZip = "fml_libs15.zip";
            fmlLibs.put("deobfuscation_data_1.5.zip", "dba6d410a91a855f3b84457c86a8132a");
            break;
        case "1.5.1":
            fmlLibsZip = "fml_libs15.zip";
            fmlLibs.put("deobfuscation_data_1.5.1.zip", "c4fc2fedba60d920e4c7f9a095b2b883");
            break;
        case "1.5.2":
            fmlLibsZip = "fml_libs15.zip";
            fmlLibs.put("deobfuscation_data_1.5.2.zip", "270d9775872cc9fa773389812cab91fe");
            break;
        default:
            fmlLibsZip = "";
    }
    if (!fmlLibsZip.isEmpty()) {
        verifyingFiles.addTask(new EnsureFileTask(new File(directories.getCacheDirectory(), fmlLibsZip), new ValidZipFileVerifier(), modpackFmlLibDir, TechnicConstants.technicFmlLibRepo + fmlLibsZip, installingLibs, installingLibs));
    }
    if (!fmlLibs.isEmpty()) {
        fmlLibs.forEach((name, md5) -> {
            MD5FileVerifier verifier = null;
            if (!md5.isEmpty())
                verifier = new MD5FileVerifier(md5);
            File cached = new File(directories.getCacheDirectory(), name);
            File target = new File(modpackFmlLibDir, name);
            if (!target.exists() || (verifier != null && !verifier.isFileValid(target))) {
                verifyingFiles.addTask(new EnsureFileTask(cached, verifier, null, TechnicConstants.technicFmlLibRepo + name, installingLibs, installingLibs));
                installingLibs.addTask(new CopyFileTask(cached, target));
            }
        });
    }
    if (doFullInstall) {
        // If we're installing a new version of modpack, then we need to get rid of the existing version.json
        File versionFile = new File(modpack.getBinDir(), "version.json");
        if (versionFile.exists()) {
            if (!versionFile.delete()) {
                throw new CacheDeleteException(versionFile.getAbsolutePath());
            }
        }
        // Remove bin/install_profile.json, which is used by ForgeWrapper to install Forge in Minecraft 1.13+
        // (and the latest few Forge builds in 1.12.2)
        File installProfileFile = new File(modpack.getBinDir(), "install_profile.json");
        if (installProfileFile.exists()) {
            if (!installProfileFile.delete()) {
                throw new CacheDeleteException(installProfileFile.getAbsolutePath());
            }
        }
        // Delete all other version JSON files in the bin dir
        File[] binFiles = modpack.getBinDir().listFiles();
        if (binFiles != null) {
            final Pattern minecraftVersionPattern = Pattern.compile("^[0-9]+(\\.[0-9]+)+\\.json$");
            for (File binFile : binFiles) {
                if (minecraftVersionPattern.matcher(binFile.getName()).matches()) {
                    if (!binFile.delete()) {
                        throw new CacheDeleteException(binFile.getAbsolutePath());
                    }
                }
            }
        }
        // Remove the runData file between updates/reinstall as well
        File runData = new File(modpack.getBinDir(), "runData");
        if (runData.exists()) {
            if (!runData.delete()) {
                throw new CacheDeleteException(runData.getAbsolutePath());
            }
        }
        // Remove the bin/modpack.jar file
        // This prevents issues when upgrading a modpack between a version that has a modpack.jar, and
        // one that doesn't. One example of this is updating BareBonesPack from a Forge to a Fabric build.
        File modpackJar = new File(modpack.getBinDir(), "modpack.jar");
        if (modpackJar.exists()) {
            if (!modpackJar.delete()) {
                throw new CacheDeleteException(modpackJar.getAbsolutePath());
            }
        }
        examineModpackData.addTask(new CleanupAndExtractModpackTask(modpack, modpackData, verifyingFiles, downloadingMods, installingMods));
    }
    if (doFullInstall)
        rundataTaskGroup.addTask(new WriteRundataFile(modpack, modpackData));
    else
        rundataTaskGroup.addTask(new CheckRundataFile(modpack, modpackData, rundataTaskGroup));
    checkVersionFile.addTask(new VerifyVersionFilePresentTask(modpack, minecraft, versionBuilder));
    examineVersionFile.addTask(new HandleVersionFileTask(modpack, directories, checkNonMavenLibs, grabLibs, installingLibs, installingLibs, versionBuilder));
    examineVersionFile.addTask(new EnsureAssetsIndexTask(directories.getAssetsDirectory(), modpack, installingMinecraft, examineIndex, verifyingAssets, installingAssets, installingAssets));
    examineJava.addTask(new EnsureJavaRuntimeManifestTask(directories.getRuntimesDirectory(), modpack, examineJava, downloadJava));
    if (doFullInstall || (installedVersion != null && installedVersion.isLegacy()))
        installingMinecraft.addTask(new InstallMinecraftIfNecessaryTask(modpack, minecraft, directories.getCacheDirectory()));
}
Also used : Pattern(java.util.regex.Pattern) Modpack(net.technicpack.rest.io.Modpack) HashMap(java.util.HashMap) CacheDeleteException(net.technicpack.launchercore.exception.CacheDeleteException) MD5FileVerifier(net.technicpack.launchercore.install.verifiers.MD5FileVerifier) ValidZipFileVerifier(net.technicpack.launchercore.install.verifiers.ValidZipFileVerifier) IJavaVersion(net.technicpack.launchercore.launch.java.IJavaVersion) Version(net.technicpack.launchercore.install.Version) MojangVersion(net.technicpack.minecraftcore.mojang.version.MojangVersion) PackInfo(net.technicpack.rest.io.PackInfo) File(java.io.File)

Aggregations

Modpack (net.technicpack.rest.io.Modpack)3 File (java.io.File)1 HashMap (java.util.HashMap)1 Pattern (java.util.regex.Pattern)1 BuildInaccessibleException (net.technicpack.launchercore.exception.BuildInaccessibleException)1 CacheDeleteException (net.technicpack.launchercore.exception.CacheDeleteException)1 Version (net.technicpack.launchercore.install.Version)1 MD5FileVerifier (net.technicpack.launchercore.install.verifiers.MD5FileVerifier)1 ValidZipFileVerifier (net.technicpack.launchercore.install.verifiers.ValidZipFileVerifier)1 IJavaVersion (net.technicpack.launchercore.launch.java.IJavaVersion)1 MojangVersion (net.technicpack.minecraftcore.mojang.version.MojangVersion)1 RestfulAPIException (net.technicpack.rest.RestfulAPIException)1 PackInfo (net.technicpack.rest.io.PackInfo)1