hmmm
This commit is contained in:
@@ -28,7 +28,6 @@ allprojects{
|
|||||||
gdxVersion = '1.9.10'
|
gdxVersion = '1.9.10'
|
||||||
roboVMVersion = '2.3.8'
|
roboVMVersion = '2.3.8'
|
||||||
steamworksVersion = '891ed912791e01fe9ee6237a6497e5212b85c256'
|
steamworksVersion = '891ed912791e01fe9ee6237a6497e5212b85c256'
|
||||||
graalVersion = '19.3.0'
|
|
||||||
arcHash = null
|
arcHash = null
|
||||||
|
|
||||||
loadVersionProps = {
|
loadVersionProps = {
|
||||||
@@ -155,7 +154,6 @@ project(":desktop"){
|
|||||||
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
|
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
|
||||||
|
|
||||||
compile "com.github.Anuken:steamworks4j:$steamworksVersion"
|
compile "com.github.Anuken:steamworks4j:$steamworksVersion"
|
||||||
compile "org.graalvm.js:js:${graalVersion}"
|
|
||||||
|
|
||||||
compile arcModule("backends:backend-sdl")
|
compile arcModule("backends:backend-sdl")
|
||||||
compile 'com.github.MinnDevelopment:java-discord-rpc:v2.0.1'
|
compile 'com.github.MinnDevelopment:java-discord-rpc:v2.0.1'
|
||||||
@@ -259,6 +257,7 @@ project(":core"){
|
|||||||
compile arcModule("arc-core")
|
compile arcModule("arc-core")
|
||||||
compile arcModule("extensions:freetype")
|
compile arcModule("extensions:freetype")
|
||||||
compile arcModule("extensions:arcnet")
|
compile arcModule("extensions:arcnet")
|
||||||
|
compile "org.mozilla:rhino:1.7.11"
|
||||||
if(localArc() && debugged()) compile arcModule("extensions:recorder")
|
if(localArc() && debugged()) compile arcModule("extensions:recorder")
|
||||||
|
|
||||||
compileOnly project(":annotations")
|
compileOnly project(":annotations")
|
||||||
|
|||||||
@@ -1,16 +1,41 @@
|
|||||||
package io.anuke.mindustry.mod;
|
package io.anuke.mindustry.mod;
|
||||||
|
|
||||||
|
import io.anuke.arc.*;
|
||||||
import io.anuke.arc.files.*;
|
import io.anuke.arc.files.*;
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
|
import io.anuke.mindustry.*;
|
||||||
import io.anuke.mindustry.mod.Mods.*;
|
import io.anuke.mindustry.mod.Mods.*;
|
||||||
|
import org.mozilla.javascript.*;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
public class Scripts{
|
public class Scripts{
|
||||||
|
private static final Class[] denied = {FileHandle.class, InputStream.class, File.class, Scripts.class, Files.class, ClassAccess.class};
|
||||||
|
private final Context context;
|
||||||
|
private final String wrapper;
|
||||||
|
private Context console;
|
||||||
|
private Scriptable scope;
|
||||||
|
|
||||||
|
public Scripts(){
|
||||||
|
Time.mark();
|
||||||
|
|
||||||
|
context = Context.enter();
|
||||||
|
if(Vars.mobile){
|
||||||
|
context.setOptimizationLevel(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
scope = context.initStandardObjects();
|
||||||
|
wrapper = Core.files.internal("scripts/wrapper.js").readString();
|
||||||
|
|
||||||
|
run(wrapper);
|
||||||
|
Log.info("Time to load script engine: {0}", Time.elapsed());
|
||||||
|
}
|
||||||
|
|
||||||
public void run(LoadedMod mod, FileHandle file){
|
public void run(LoadedMod mod, FileHandle file){
|
||||||
Log.info("Skipping {0} (no scripting implenmentation)", file);
|
run(wrapper.replace("$SCRIPT_NAME$", mod.name + "_" +file.nameWithoutExtension().replace("-", "_").replace(" ", "_")).replace("$CODE$", file.readString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String runConsole(String text){
|
private void run(String script){
|
||||||
return "No scripting engine available.";
|
Log.info(context.evaluateString(scope, script, "???", 0, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,10 +19,9 @@ import io.anuke.arc.util.io.*;
|
|||||||
import io.anuke.arc.util.serialization.*;
|
import io.anuke.arc.util.serialization.*;
|
||||||
import io.anuke.mindustry.*;
|
import io.anuke.mindustry.*;
|
||||||
import io.anuke.mindustry.core.GameState.*;
|
import io.anuke.mindustry.core.GameState.*;
|
||||||
import io.anuke.mindustry.core.Version;
|
import io.anuke.mindustry.core.*;
|
||||||
import io.anuke.mindustry.desktop.steam.*;
|
import io.anuke.mindustry.desktop.steam.*;
|
||||||
import io.anuke.mindustry.game.EventType.*;
|
import io.anuke.mindustry.game.EventType.*;
|
||||||
import io.anuke.mindustry.mod.*;
|
|
||||||
import io.anuke.mindustry.mod.Mods.*;
|
import io.anuke.mindustry.mod.Mods.*;
|
||||||
import io.anuke.mindustry.net.*;
|
import io.anuke.mindustry.net.*;
|
||||||
import io.anuke.mindustry.net.Net.*;
|
import io.anuke.mindustry.net.Net.*;
|
||||||
@@ -265,11 +264,6 @@ public class DesktopLauncher extends ClientLauncher{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Scripts createScripts(){
|
|
||||||
return new GraalScripts();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Array<FileHandle> getWorkshopContent(Class<? extends Publishable> type){
|
public Array<FileHandle> getWorkshopContent(Class<? extends Publishable> type){
|
||||||
return !steam ? super.getWorkshopContent(type) : SVars.workshop.getWorkshopFiles(type);
|
return !steam ? super.getWorkshopContent(type) : SVars.workshop.getWorkshopFiles(type);
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
package io.anuke.mindustry.desktop;
|
|
||||||
|
|
||||||
import io.anuke.arc.*;
|
|
||||||
import io.anuke.arc.files.*;
|
|
||||||
import io.anuke.arc.util.*;
|
|
||||||
import io.anuke.mindustry.mod.*;
|
|
||||||
import io.anuke.mindustry.mod.Mods.*;
|
|
||||||
import org.graalvm.polyglot.*;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
|
|
||||||
public class GraalScripts extends Scripts{
|
|
||||||
private static final Class[] denied = {FileHandle.class, InputStream.class, File.class, Scripts.class, Files.class, ClassAccess.class};
|
|
||||||
private final Context context;
|
|
||||||
private final String wrapper;
|
|
||||||
private final Context.Builder builder;
|
|
||||||
private Context console;
|
|
||||||
|
|
||||||
public GraalScripts(){
|
|
||||||
Time.mark();
|
|
||||||
builder = Context.newBuilder("js").allowHostClassLookup(ClassAccess.allowedClassNames::contains);
|
|
||||||
|
|
||||||
HostAccess.Builder hb = HostAccess.newBuilder();
|
|
||||||
hb.allowPublicAccess(true);
|
|
||||||
for(Class c : denied){
|
|
||||||
hb.denyAccess(c);
|
|
||||||
}
|
|
||||||
builder.allowHostAccess(hb.build());
|
|
||||||
builder.allowExperimentalOptions(true);
|
|
||||||
|
|
||||||
context = builder.build();
|
|
||||||
wrapper = Core.files.internal("scripts/wrapper.js").readString();
|
|
||||||
|
|
||||||
run(Core.files.internal("scripts/global.js").readString());
|
|
||||||
Log.info("Time to load script engine: {0}", Time.elapsed());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run(LoadedMod mod, FileHandle file){
|
|
||||||
run(wrapper.replace("$SCRIPT_NAME$", mod.name + "_" +file.nameWithoutExtension().replace("-", "_").replace(" ", "_")).replace("$CODE$", file.readString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String runConsole(String text){
|
|
||||||
if(console == null){
|
|
||||||
console = builder.build();
|
|
||||||
}
|
|
||||||
return console.eval("js", text).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void run(String script){
|
|
||||||
context.eval("js", script);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||||
archash=c7f3d8125c8d13c0a31c5f14fdabdb3d0efbd676
|
archash=680d8dfc055a1336c06b32d7d4429661e6c6fddd
|
||||||
|
|||||||
Reference in New Issue
Block a user