diff --git a/src/main/java/pw/yumc/MiaoScript/MiaoScript.java b/src/main/java/pw/yumc/MiaoScript/MiaoScript.java index 229ac91..0b00809 100644 --- a/src/main/java/pw/yumc/MiaoScript/MiaoScript.java +++ b/src/main/java/pw/yumc/MiaoScript/MiaoScript.java @@ -46,7 +46,7 @@ public class MiaoScript extends JavaPlugin implements Executor { @Help("执行 JS 代码文件") @SneakyThrows public void file(CommandSender sender, String file) { - result(sender, engine.eval(new FileReader(new File(getDataFolder(), file)))); + result(sender, engine.eval("load('" + new File(getDataFolder(), file).getCanonicalPath() + "')")); } @Cmd @@ -66,7 +66,7 @@ public class MiaoScript extends JavaPlugin implements Executor { } private void saveScript() { - P.saveFile(true, "core", "modules", "kit"); + P.saveFile(true, "core", "modules"); } private void enableEngine() { @@ -75,7 +75,7 @@ public class MiaoScript extends JavaPlugin implements Executor { currentThread.setContextClassLoader(getClassLoader()); try { ScriptEngineManager manager = new ScriptEngineManager(); - this.engine = new MiaoScriptEngine(manager); + this.engine = new MiaoScriptEngine(manager, "nashorn"); this.engine.put("base", new Base()); this.engine.eval(new InputStreamReader(this.getResource("bios.js"))); engine.invokeFunction("boot", this); diff --git a/src/main/resources/kit/reflect.js b/src/main/resources/core/reflect.js similarity index 100% rename from src/main/resources/kit/reflect.js rename to src/main/resources/core/reflect.js diff --git a/src/main/resources/modules/bukkit.js b/src/main/resources/modules/bukkit.js index 3e45a40..16e06c7 100644 --- a/src/main/resources/modules/bukkit.js +++ b/src/main/resources/modules/bukkit.js @@ -8,6 +8,7 @@ var Bukkit = Java.type("org.bukkit.Bukkit"); // noinspection JSUnresolvedVariable var PluginManager = Bukkit.pluginManager; +exports.$ = Bukkit; /** * 插件管理 * @type {{manager: *, get: exports.plugin.get, load: exports.plugin.load}} diff --git a/src/main/resources/modules/event.js b/src/main/resources/modules/event.js index 538e185..ee78d67 100644 --- a/src/main/resources/modules/event.js +++ b/src/main/resources/modules/event.js @@ -15,7 +15,7 @@ var IllegalStateException = Java.type("java.lang.IllegalStateException"); var plugin = base.plugin; -var ref = require('kit/reflect'); +var ref = require('reflect'); var jspListener = [];