Handle all mod loading exceptions

This commit is contained in:
Bixilon 2020-11-22 19:40:59 +01:00
parent 82cd21ddf9
commit 0fba4510df
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -23,7 +23,6 @@ import org.xeustechnologies.jcl.JarClassLoader;
import org.xeustechnologies.jcl.JclObjectFactory;
import java.io.File;
import java.io.IOException;
import java.util.LinkedList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
@ -87,7 +86,12 @@ public class ModLoader {
progress.countDown();
return;
}
try {
if (!instance.start(phase)) {
throw new ModLoadingException(String.format("Could not load nod %s", instance.getInfo()));
}
} catch (Throwable e) {
e.printStackTrace();
Log.warn(String.format("An error occurred while loading %s", instance.getInfo()));
instance.setEnabled(false);
}
@ -127,7 +131,7 @@ public class ModLoader {
instance.setInfo(modInfo);
Log.verbose(String.format("[MOD] Mod file loaded and added to classpath (%s)", modInfo));
zipFile.close();
} catch (IOException | ModLoadingException | NullPointerException e) {
} catch (Throwable e) {
instance = null;
e.printStackTrace();
Log.warn(String.format("Could not load mod: %s", file.getAbsolutePath()));