Better JSON null validation / Disable mods on startup crash
This commit is contained in:
@@ -406,6 +406,12 @@ public class ContentParser{
|
||||
this.currentMod = mod;
|
||||
this.currentContent = cont;
|
||||
run.run();
|
||||
|
||||
//check nulls after parsing
|
||||
if(cont != null){
|
||||
toBeParsed.remove(cont);
|
||||
checkNullFields(cont);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -259,6 +259,11 @@ public class Mods implements Loadable{
|
||||
return requiresReload;
|
||||
}
|
||||
|
||||
/** @return whether to skip mod loading due to previous initialization failure. */
|
||||
public boolean skipModLoading(){
|
||||
return failedToLaunch && Core.settings.getBool("modcrashdisable", true);
|
||||
}
|
||||
|
||||
/** Loads all mods from the folder, but does not call any methods on them.*/
|
||||
public void load(){
|
||||
for(Fi file : modDirectory.list()){
|
||||
@@ -683,8 +688,13 @@ public class Mods implements Loadable{
|
||||
|
||||
//make sure the main class exists before loading it; if it doesn't just don't put it there
|
||||
//if the mod is explicitly marked as java, try loading it anyway
|
||||
if((mainFile.exists() || meta.java) &&
|
||||
Core.settings.getBool("mod-" + baseName + "-enabled", true) && Version.isAtLeast(meta.minGameVersion) && (meta.getMinMajor() >= 105 || headless)){
|
||||
if(
|
||||
(mainFile.exists() || meta.java) &&
|
||||
!skipModLoading() &&
|
||||
Core.settings.getBool("mod-" + baseName + "-enabled", true) &&
|
||||
Version.isAtLeast(meta.minGameVersion) &&
|
||||
(meta.getMinMajor() >= 105 || headless)
|
||||
){
|
||||
|
||||
if(ios){
|
||||
throw new IllegalArgumentException("Java class mods are not supported on iOS.");
|
||||
@@ -711,11 +721,16 @@ public class Mods implements Loadable{
|
||||
}
|
||||
}
|
||||
|
||||
//skip mod loading if it failed
|
||||
if(skipModLoading()){
|
||||
Core.settings.put("mod-" + baseName + "-enabled", false);
|
||||
}
|
||||
|
||||
if(!headless){
|
||||
Log.info("Loaded mod '@' in @ms", meta.name, Time.elapsed());
|
||||
}
|
||||
return new LoadedMod(sourceFile, zip, mainMod, loader, meta);
|
||||
|
||||
return new LoadedMod(sourceFile, zip, mainMod, loader, meta);
|
||||
}catch(Exception e){
|
||||
//delete root zip file so it can be closed on windows
|
||||
if(rootZip != null) rootZip.delete();
|
||||
|
||||
Reference in New Issue
Block a user