refactor: 移动反射工具
This commit is contained in:
parent
fb16a16107
commit
8e30399465
@ -46,7 +46,7 @@ public class MiaoScript extends JavaPlugin implements Executor {
|
|||||||
@Help("执行 JS 代码文件")
|
@Help("执行 JS 代码文件")
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public void file(CommandSender sender, String file) {
|
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
|
@Cmd
|
||||||
@ -66,7 +66,7 @@ public class MiaoScript extends JavaPlugin implements Executor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void saveScript() {
|
private void saveScript() {
|
||||||
P.saveFile(true, "core", "modules", "kit");
|
P.saveFile(true, "core", "modules");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableEngine() {
|
private void enableEngine() {
|
||||||
@ -75,7 +75,7 @@ public class MiaoScript extends JavaPlugin implements Executor {
|
|||||||
currentThread.setContextClassLoader(getClassLoader());
|
currentThread.setContextClassLoader(getClassLoader());
|
||||||
try {
|
try {
|
||||||
ScriptEngineManager manager = new ScriptEngineManager();
|
ScriptEngineManager manager = new ScriptEngineManager();
|
||||||
this.engine = new MiaoScriptEngine(manager);
|
this.engine = new MiaoScriptEngine(manager, "nashorn");
|
||||||
this.engine.put("base", new Base());
|
this.engine.put("base", new Base());
|
||||||
this.engine.eval(new InputStreamReader(this.getResource("bios.js")));
|
this.engine.eval(new InputStreamReader(this.getResource("bios.js")));
|
||||||
engine.invokeFunction("boot", this);
|
engine.invokeFunction("boot", this);
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
var Bukkit = Java.type("org.bukkit.Bukkit");
|
var Bukkit = Java.type("org.bukkit.Bukkit");
|
||||||
// noinspection JSUnresolvedVariable
|
// noinspection JSUnresolvedVariable
|
||||||
var PluginManager = Bukkit.pluginManager;
|
var PluginManager = Bukkit.pluginManager;
|
||||||
|
exports.$ = Bukkit;
|
||||||
/**
|
/**
|
||||||
* 插件管理
|
* 插件管理
|
||||||
* @type {{manager: *, get: exports.plugin.get, load: exports.plugin.load}}
|
* @type {{manager: *, get: exports.plugin.get, load: exports.plugin.load}}
|
||||||
|
@ -15,7 +15,7 @@ var IllegalStateException = Java.type("java.lang.IllegalStateException");
|
|||||||
|
|
||||||
var plugin = base.plugin;
|
var plugin = base.plugin;
|
||||||
|
|
||||||
var ref = require('kit/reflect');
|
var ref = require('reflect');
|
||||||
|
|
||||||
var jspListener = [];
|
var jspListener = [];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user