prevent NPE

This commit is contained in:
Anthony Calosa
2024-10-26 06:05:03 +08:00
parent 6f3debba7a
commit e6e6a6e0a4

View File

@@ -119,12 +119,14 @@ public class ImageCache {
public static void disposeTextures() { public static void disposeTextures() {
CardRenderer.clearcardArtCache(); CardRenderer.clearcardArtCache();
//unload all cardsLoaded //unload all cardsLoaded
if (cardsLoaded != null) {
for (String fileName : cardsLoaded) { for (String fileName : cardsLoaded) {
if (Forge.getAssets().manager().get(fileName, Texture.class, false) != null) { if (Forge.getAssets().manager().get(fileName, Texture.class, false) != null) {
Forge.getAssets().manager().unload(fileName); Forge.getAssets().manager().unload(fileName);
} }
} }
cardsLoaded.clear(); cardsLoaded.clear();
}
((Forge) Gdx.app.getApplicationListener()).needsUpdate = true; ((Forge) Gdx.app.getApplicationListener()).needsUpdate = true;
} }