create new branch
This commit is contained in:
@@ -460,10 +460,26 @@ public class Mods implements Loadable{
|
|||||||
eachEnabled(mod -> {
|
eachEnabled(mod -> {
|
||||||
if(mod.root.child("scripts").exists()){
|
if(mod.root.child("scripts").exists()){
|
||||||
content.setCurrentMod(mod);
|
content.setCurrentMod(mod);
|
||||||
mod.scripts = mod.root.child("scripts").findAll(f -> f.extension().equals("js"));
|
if(mod.meta.mainScript == null){
|
||||||
Log.debug("[{0}] Found {1} scripts.", mod.meta.name, mod.scripts.size);
|
mod.scripts = mod.root.child("scripts").findAll(f -> f.extension().equals("js"));
|
||||||
|
Log.debug("[{0}] Found {1} scripts.", mod.meta.name, mod.scripts.size);
|
||||||
|
|
||||||
for(Fi file : mod.scripts){
|
for(Fi file : mod.scripts){
|
||||||
|
try{
|
||||||
|
if(scripts == null){
|
||||||
|
scripts = platform.createScripts();
|
||||||
|
}
|
||||||
|
scripts.run(mod, file);
|
||||||
|
}catch(Throwable e){
|
||||||
|
Core.app.post(() -> {
|
||||||
|
Log.err("Error loading script {0} for mod {1}.", file.name(), mod.meta.name);
|
||||||
|
e.printStackTrace();
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
Fi file = new Fi(mod.meta.mainscript + ".js");
|
||||||
try{
|
try{
|
||||||
if(scripts == null){
|
if(scripts == null){
|
||||||
scripts = platform.createScripts();
|
scripts = platform.createScripts();
|
||||||
@@ -471,10 +487,9 @@ public class Mods implements Loadable{
|
|||||||
scripts.run(mod, file);
|
scripts.run(mod, file);
|
||||||
}catch(Throwable e){
|
}catch(Throwable e){
|
||||||
Core.app.post(() -> {
|
Core.app.post(() -> {
|
||||||
Log.err("Error loading script {0} for mod {1}.", file.name(), mod.meta.name);
|
Log.err("Error loading main script {0} for mod {1}.", file.name(), mod.meta.name);
|
||||||
e.printStackTrace();
|
e.printStacktrace();
|
||||||
});
|
});
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -794,7 +809,7 @@ public class Mods implements Loadable{
|
|||||||
|
|
||||||
/** Plugin metadata information.*/
|
/** Plugin metadata information.*/
|
||||||
public static class ModMeta{
|
public static class ModMeta{
|
||||||
public String name, displayName, author, description, version, main, minGameVersion;
|
public String name, displayName, author, description, version, main, minGameVersion, mainScript;
|
||||||
public Array<String> dependencies = Array.with();
|
public Array<String> dependencies = Array.with();
|
||||||
/** Hidden mods are only server-side or client-side, and do not support adding new content. */
|
/** Hidden mods are only server-side or client-side, and do not support adding new content. */
|
||||||
public boolean hidden;
|
public boolean hidden;
|
||||||
|
|||||||
Reference in New Issue
Block a user