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