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 {
|
public void execute() throws Exception {
|
||||||
AssetIndex index;
|
AssetIndex index;
|
||||||
try {
|
try {
|
||||||
index = JsonUtils.GSON.fromJson(FileUtils.readText(assetIndexFile), AssetIndex.class);
|
index = JsonUtils.fromNonNullJson(FileUtils.readText(assetIndexFile), AssetIndex.class);
|
||||||
} catch (IOException | JsonSyntaxException e) {
|
} catch (IOException | JsonParseException e) {
|
||||||
throw new GameAssetIndexDownloadTask.GameAssetIndexMalformedException();
|
throw new GameAssetIndexDownloadTask.GameAssetIndexMalformedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
int progress = 0;
|
int progress = 0;
|
||||||
if (index != null)
|
|
||||||
for (AssetObject assetObject : index.getObjects().values()) {
|
for (AssetObject assetObject : index.getObjects().values()) {
|
||||||
if (isCancelled())
|
if (isCancelled())
|
||||||
throw new InterruptedException();
|
throw new InterruptedException();
|
||||||
|
|||||||
Reference in New Issue
Block a user