mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-28 07:22:21 -08:00
Single-script mod case
This commit is contained in:
parent
9c2569d4f5
commit
eb87e5f265
2 changed files with 12 additions and 11 deletions
|
|
@ -5,17 +5,16 @@ import arc.files.*;
|
|||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import arc.util.Log.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.regex.*;
|
||||
import mindustry.*;
|
||||
import mindustry.mod.Mods.*;
|
||||
import org.mozilla.javascript.*;
|
||||
import org.mozilla.javascript.commonjs.module.*;
|
||||
import org.mozilla.javascript.commonjs.module.provider.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Scripts implements Disposable{
|
||||
private final Array<String> blacklist = Array.with("net", "files", "reflect", "javax", "rhino", "file", "channels", "jdk",
|
||||
"runtime", "util.os", "rmi", "security", "org.", "sun.", "beans", "sql", "http", "exec", "compiler", "process", "system",
|
||||
|
|
@ -116,20 +115,20 @@ public class Scripts implements Disposable{
|
|||
@Override
|
||||
public ModuleSource loadSource(String moduleId, Scriptable paths, Object validator) throws IOException, URISyntaxException{
|
||||
if(loadedMod == null) return null;
|
||||
return loadSource(loadedMod, moduleId, loadedMod.root.child("scripts"), validator);
|
||||
return loadSource(moduleId, loadedMod.root.child("scripts"), validator);
|
||||
}
|
||||
|
||||
private ModuleSource loadSource(LoadedMod mod, String moduleId, Fi root, Object validator) throws IOException, URISyntaxException{
|
||||
private ModuleSource loadSource(String moduleId, Fi root, Object validator) throws URISyntaxException{
|
||||
Matcher matched = directory.matcher(moduleId);
|
||||
if(matched.find()){
|
||||
LoadedMod required = Vars.mods.locateMod(matched.group(1));
|
||||
String script = matched.group(2);
|
||||
if(required == null || root == required.root.child("scripts")){ // Mod not found, or already using a mod
|
||||
if(required == null || root.equals(required.root.child("scripts"))){ // Mod not found, or already using a mod
|
||||
Fi dir = root.child(matched.group(1));
|
||||
if(!dir.exists()) return null; // Mod and folder not found
|
||||
return loadSource(mod, script, dir, validator);
|
||||
return loadSource(script, dir, validator);
|
||||
}
|
||||
return loadSource(required, script, required.root.child("scripts"), validator);
|
||||
return loadSource(script, required.root.child("scripts"), validator);
|
||||
}
|
||||
|
||||
Fi module = root.child(moduleId + ".js");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue