Fix NullPointerException when trying to load textures from an empty textures.json file

This commit is contained in:
Lukas Rieger (Blue) 2023-02-10 17:02:15 +01:00
parent cc01585e07
commit 310a2e55eb
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2

View File

@ -69,6 +69,7 @@ public static TextureGallery readTexturesFile(InputStream in) throws IOException
TextureGallery gallery = new TextureGallery();
try (Reader reader = new InputStreamReader(in)) {
Texture[] textures = ResourcesGson.INSTANCE.fromJson(reader, Texture[].class);
if (textures == null) throw new IOException("Texture data is empty!");
gallery.nextId = textures.length;
for (int ordinal = 0; ordinal < textures.length; ordinal++) {
Texture texture = textures[ordinal];