mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-05 07:47:48 +07:00
Tweaks
This commit is contained in:
@ -28,6 +28,7 @@ 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 = {
|
||||||
@ -154,8 +155,10 @@ 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:19.3.0"
|
compile "org.graalvm.js:js:${graalVersion}"
|
||||||
compile "org.graalvm.sdk:graal-sdk:19.3.0"
|
compile "org.graalvm.sdk:graal-sdk:${graalVersion}"
|
||||||
|
compile "org.graalvm.truffle:truffle-api:${graalVersion}"
|
||||||
|
compile "org.graalvm.regex:regex:${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'
|
||||||
|
@ -3,6 +3,7 @@ const Core = Java.type('io.anuke.arc.Core')
|
|||||||
const Draw = Java.type('io.anuke.arc.graphics.g2d.Draw')
|
const Draw = Java.type('io.anuke.arc.graphics.g2d.Draw')
|
||||||
const TextureAtlas = Java.type('io.anuke.arc.graphics.g2d.TextureAtlas')
|
const TextureAtlas = Java.type('io.anuke.arc.graphics.g2d.TextureAtlas')
|
||||||
const TextureRegion = Java.type('io.anuke.arc.graphics.g2d.TextureRegion')
|
const TextureRegion = Java.type('io.anuke.arc.graphics.g2d.TextureRegion')
|
||||||
|
const Time = Java.type('io.anuke.arc.util.Time')
|
||||||
const Vars = Java.type('io.anuke.mindustry.Vars')
|
const Vars = Java.type('io.anuke.mindustry.Vars')
|
||||||
const BlockIndexer = Java.type('io.anuke.mindustry.ai.BlockIndexer')
|
const BlockIndexer = Java.type('io.anuke.mindustry.ai.BlockIndexer')
|
||||||
const Pathfinder = Java.type('io.anuke.mindustry.ai.Pathfinder')
|
const Pathfinder = Java.type('io.anuke.mindustry.ai.Pathfinder')
|
||||||
|
@ -5,5 +5,5 @@ $CODE$
|
|||||||
try{
|
try{
|
||||||
this["$SCRIPT_NAME$"]();
|
this["$SCRIPT_NAME$"]();
|
||||||
}catch(e){
|
}catch(e){
|
||||||
console.log(e)
|
print(e)
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -9,4 +9,8 @@ public class Scripts{
|
|||||||
public void run(LoadedMod mod, FileHandle file){
|
public void run(LoadedMod mod, FileHandle file){
|
||||||
Log.info("Skipping {0} (no scripting implenmentation)", file);
|
Log.info("Skipping {0} (no scripting implenmentation)", file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String runConsole(String text){
|
||||||
|
return "No scripting engine available.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,10 +13,12 @@ public class GraalScripts extends Scripts{
|
|||||||
private static final Class[] denied = {FileHandle.class, InputStream.class, File.class, Scripts.class, Files.class, ClassAccess.class};
|
private static final Class[] denied = {FileHandle.class, InputStream.class, File.class, Scripts.class, Files.class, ClassAccess.class};
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private final String wrapper;
|
private final String wrapper;
|
||||||
|
private final Context.Builder builder;
|
||||||
|
private Context console;
|
||||||
|
|
||||||
public GraalScripts(){
|
public GraalScripts(){
|
||||||
Time.mark();
|
Time.mark();
|
||||||
Context.Builder builder = Context.newBuilder("js").allowHostClassLookup(ClassAccess.allowedClassNames::contains);
|
builder = Context.newBuilder("js").allowHostClassLookup(ClassAccess.allowedClassNames::contains);
|
||||||
|
|
||||||
HostAccess.Builder hb = HostAccess.newBuilder();
|
HostAccess.Builder hb = HostAccess.newBuilder();
|
||||||
hb.allowPublicAccess(true);
|
hb.allowPublicAccess(true);
|
||||||
@ -33,10 +35,19 @@ public class GraalScripts extends Scripts{
|
|||||||
Log.info("Time to load script engine: {0}", Time.elapsed());
|
Log.info("Time to load script engine: {0}", Time.elapsed());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void run(LoadedMod mod, FileHandle file){
|
public void run(LoadedMod mod, FileHandle file){
|
||||||
run(wrapper.replace("$SCRIPT_NAME$", mod.name + "_" +file.nameWithoutExtension().replace("-", "_").replace(" ", "_")).replace("$CODE$", file.readString()));
|
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){
|
private void run(String script){
|
||||||
context.eval("js", script);
|
context.eval("js", script);
|
||||||
}
|
}
|
||||||
|
@ -17,15 +17,15 @@ public class ScriptStubGenerator{
|
|||||||
String base = "io.anuke.mindustry";
|
String base = "io.anuke.mindustry";
|
||||||
Array<String> blacklist = Array.with("plugin", "mod", "net", "io", "tools", "gen");
|
Array<String> blacklist = Array.with("plugin", "mod", "net", "io", "tools", "gen");
|
||||||
Array<String> nameBlacklist = Array.with("ClientLauncher", "NetClient", "NetServer");
|
Array<String> nameBlacklist = Array.with("ClientLauncher", "NetClient", "NetServer");
|
||||||
Array<Class<?>> whitelist = Array.with(Draw.class, Core.class, TextureAtlas.class, TextureRegion.class);
|
Array<Class<?>> whitelist = Array.with(Draw.class, Core.class, TextureAtlas.class, TextureRegion.class, Time.class);
|
||||||
|
|
||||||
String fileTemplate = "package io.anuke.mindustry.mod;\n" +
|
String fileTemplate = "package io.anuke.mindustry.mod;\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"import io.anuke.arc.collection.*;\n" +
|
"import io.anuke.arc.collection.*;\n" +
|
||||||
"//obviously autogenerated, do not touch\n" +
|
"//obviously autogenerated, do not touch\n" +
|
||||||
"class ClassAccess{\n" +
|
"public class ClassAccess{\n" +
|
||||||
//"\tstatic final Array<Class<?>> allowedClasses = Array.with($ALLOWED_CLASSES$);\n" +
|
//"\tstatic final Array<Class<?>> allowedClasses = Array.with($ALLOWED_CLASSES$);\n" +
|
||||||
"\tstatic final ObjectSet<String> allowedClassNames = ObjectSet.with($ALLOWED_CLASS_NAMES$);\n" +
|
"\tpublic static final ObjectSet<String> allowedClassNames = ObjectSet.with($ALLOWED_CLASS_NAMES$);\n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
List<ClassLoader> classLoadersList = new LinkedList<>();
|
List<ClassLoader> classLoadersList = new LinkedList<>();
|
||||||
|
Reference in New Issue
Block a user