Skip to content

Commit bad575b

Browse files
committed
Annotate FetchManager as nullable and handle it
1 parent 497ddab commit bad575b

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

loader/core/src/main/java/pl/skidam/automodpack_loader_core/client/ModpackUpdater.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package pl.skidam.automodpack_loader_core.client;
22

3+
import org.jetbrains.annotations.Nullable;
34
import pl.skidam.automodpack_core.auth.Secrets;
45
import pl.skidam.automodpack_core.auth.SecretsStore;
56
import pl.skidam.automodpack_core.config.Jsons;
@@ -28,7 +29,6 @@
2829
public class ModpackUpdater {
2930
public Changelogs changelogs = new Changelogs();
3031
public DownloadManager downloadManager;
31-
public FetchManager fetchManager;
3232
public long totalBytesToDownload = 0;
3333
public boolean fullDownload = false;
3434
private Jsons.ModpackContentFields serverModpackContent;
@@ -201,6 +201,8 @@ public void startUpdate(Set<Jsons.ModpackContentFields.ModpackContentItem> files
201201
}
202202
}
203203

204+
FetchManager fetchManager = null;
205+
204206
if (!fetchDatas.isEmpty()) {
205207
fetchManager = new FetchManager(fetchDatas);
206208
new ScreenManager().fetch(fetchManager);
@@ -210,7 +212,7 @@ public void startUpdate(Set<Jsons.ModpackContentFields.ModpackContentItem> files
210212

211213
// DOWNLOAD
212214
try {
213-
downloadModpack(finalFilesToUpdate, startFetching, cache);
215+
downloadModpack(finalFilesToUpdate, startFetching, fetchManager, cache);
214216

215217
LOGGER.info("Done, saving {}", modpackContentFile);
216218

@@ -253,7 +255,7 @@ public void startUpdate(Set<Jsons.ModpackContentFields.ModpackContentItem> files
253255
}
254256
}
255257

256-
private void downloadModpack(Set<Jsons.ModpackContentFields.ModpackContentItem> finalFilesToUpdate, long startFetching, FileMetadataCache cache) throws InterruptedException {
258+
private void downloadModpack(Set<Jsons.ModpackContentFields.ModpackContentItem> finalFilesToUpdate, long startFetching, @Nullable FetchManager fetchManager, FileMetadataCache cache) throws InterruptedException {
257259
int wholeQueue = finalFilesToUpdate.size();
258260

259261
if (wholeQueue == 0) {
@@ -287,7 +289,7 @@ private void downloadModpack(Set<Jsons.ModpackContentFields.ModpackContentItem>
287289
}
288290

289291
List<String> urls = new ArrayList<>();
290-
if (fetchManager.getFetchDatas().containsKey(serverHash)) {
292+
if (fetchManager != null && fetchManager.getFetchDatas().containsKey(serverHash)) {
291293
urls.addAll(fetchManager.getFetchDatas().get(serverHash).fetchedData().urls());
292294
}
293295

0 commit comments

Comments
 (0)