fix: game crashes when asset index file is empty
This commit is contained in:
@@ -93,13 +93,12 @@ public final class GameAssetDownloadTask extends Task<Void> {
|
||||
public void execute() throws Exception {
|
||||
AssetIndex index;
|
||||
try {
|
||||
index = JsonUtils.GSON.fromJson(FileUtils.readText(assetIndexFile), AssetIndex.class);
|
||||
} catch (IOException | JsonSyntaxException e) {
|
||||
index = JsonUtils.fromNonNullJson(FileUtils.readText(assetIndexFile), AssetIndex.class);
|
||||
} catch (IOException | JsonParseException e) {
|
||||
throw new GameAssetIndexDownloadTask.GameAssetIndexMalformedException();
|
||||
}
|
||||
|
||||
int progress = 0;
|
||||
if (index != null)
|
||||
for (AssetObject assetObject : index.getObjects().values()) {
|
||||
if (isCancelled())
|
||||
throw new InterruptedException();
|
||||
|
||||
Reference in New Issue
Block a user