Search in sources :

Example 1 with InstalledPack

use of net.technicpack.launchercore.modpacks.InstalledPack in project LauncherV3 by TechnicPack.

the class TechnicInstalledPackStore method put.

@Override
public InstalledPack put(InstalledPack installedPack) {
    InstalledPack pack = installedPacks.put(installedPack.getName(), installedPack);
    if (pack == null) {
        byIndex.add(installedPack.getName());
    }
    save();
    return pack;
}
Also used : InstalledPack(net.technicpack.launchercore.modpacks.InstalledPack)

Example 2 with InstalledPack

use of net.technicpack.launchercore.modpacks.InstalledPack in project LauncherV3 by TechnicPack.

the class TechnicInstalledPackStore method remove.

@Override
public InstalledPack remove(String name) {
    InstalledPack pack = installedPacks.remove(name);
    if (pack != null) {
        byIndex.remove(name);
    }
    save();
    return pack;
}
Also used : InstalledPack(net.technicpack.launchercore.modpacks.InstalledPack)

Example 3 with InstalledPack

use of net.technicpack.launchercore.modpacks.InstalledPack in project LauncherV3 by TechnicPack.

the class InitialV3Migrator method migrate.

@Override
public void migrate(TechnicSettings settings, IInstalledPackRepository packStore, LauncherDirectories directories, IUserStore<MojangUser> users) {
    // A fresh install/upgrade from v2 shouldn't show the latest news as being new
    int maxNewsId = 0;
    try {
        for (NewsArticle article : platformApi.getNews().getArticles()) {
            int newsId = article.getId();
            if (newsId > maxNewsId)
                maxNewsId = newsId;
        }
        settings.setLatestNewsArticle(maxNewsId);
    } catch (RestfulAPIException ex) {
    // Just kill the exception & go with ID 0
    }
    List<ModpackModel> deletePacks = new LinkedList<ModpackModel>();
    for (String packName : packStore.getPackNames()) {
        InstalledPack pack = packStore.getInstalledPacks().get(packName);
        ModpackModel model = new ModpackModel(pack, null, packStore, directories);
        if (!model.getInstalledDirectory().exists()) {
            deletePacks.add(model);
        }
    }
    for (ModpackModel deletePack : deletePacks) {
        deletePack.delete();
    }
    packStore.save();
}
Also used : InstalledPack(net.technicpack.launchercore.modpacks.InstalledPack) RestfulAPIException(net.technicpack.rest.RestfulAPIException) NewsArticle(net.technicpack.platform.io.NewsArticle) ModpackModel(net.technicpack.launchercore.modpacks.ModpackModel) LinkedList(java.util.LinkedList)

Example 4 with InstalledPack

use of net.technicpack.launchercore.modpacks.InstalledPack in project LauncherV3 by TechnicPack.

the class InitialV3Migrator method migrate.

@Override
public void migrate(TechnicSettings settings, IInstalledPackRepository packStore, LauncherDirectories directories, IUserStore users) {
    // A fresh install/upgrade from v2 shouldn't show the latest news as being new
    int maxNewsId = 0;
    try {
        for (NewsArticle article : platformApi.getNews().getArticles()) {
            int newsId = article.getId();
            if (newsId > maxNewsId)
                maxNewsId = newsId;
        }
        settings.setLatestNewsArticle(maxNewsId);
    } catch (RestfulAPIException ex) {
    // Just kill the exception & go with ID 0
    }
    List<ModpackModel> deletePacks = new LinkedList<ModpackModel>();
    for (String packName : packStore.getPackNames()) {
        InstalledPack pack = packStore.getInstalledPacks().get(packName);
        ModpackModel model = new ModpackModel(pack, null, packStore, directories);
        if (!model.getInstalledDirectory().exists()) {
            deletePacks.add(model);
        }
    }
    for (ModpackModel deletePack : deletePacks) {
        deletePack.delete();
    }
    packStore.save();
}
Also used : InstalledPack(net.technicpack.launchercore.modpacks.InstalledPack) RestfulAPIException(net.technicpack.rest.RestfulAPIException) NewsArticle(net.technicpack.platform.io.NewsArticle) ModpackModel(net.technicpack.launchercore.modpacks.ModpackModel) LinkedList(java.util.LinkedList)

Aggregations

InstalledPack (net.technicpack.launchercore.modpacks.InstalledPack)4 LinkedList (java.util.LinkedList)2 ModpackModel (net.technicpack.launchercore.modpacks.ModpackModel)2 NewsArticle (net.technicpack.platform.io.NewsArticle)2 RestfulAPIException (net.technicpack.rest.RestfulAPIException)2