refactor: 移动反射工具

This commit is contained in:
coding 2017-10-11 16:37:24 +00:00
parent fb16a16107
commit 8e30399465
4 changed files with 5 additions and 4 deletions

View File

@ -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);

View File

@ -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}}

View File

@ -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 = [];