feat: 调整脚本引擎加载逻辑

This commit is contained in:
coding 2017-11-11 08:34:03 +00:00
parent 973ecf239e
commit bf8201e9d2
2 changed files with 3 additions and 2 deletions

View File

@ -89,7 +89,7 @@ public class MiaoScriptSponge {
engine.disableEngine();
Sponge.getEventManager().unregisterPluginListeners(this);
engine.enableEngine();
// src.sendMesssage("§6[§bMiaoScript§6]§r §bMiaoScript §eEngine §a重启完成!");
src.sendMessage(Text.of("§6[§bMiaoScript§6]§r §bMiaoScript §eEngine §a重启完成!"));
return CommandResult.success();
})
.build();
@ -101,5 +101,6 @@ public class MiaoScriptSponge {
Sponge.getServer().getConsole();
Sponge.getCommandManager().register(this, main(), "ms", "mscript", "MiaoScript");
engine = new ScriptEngine(pluginConfigDir.getCanonicalPath(), logger);
engine.enableEngine();
}
}

View File

@ -35,7 +35,7 @@ public class ScriptEngine {
public void enableEngine(ClassLoader loader) {
val origin = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(loader);
ScriptEngineManager manager = new ScriptEngineManager(null);
ScriptEngineManager manager = new ScriptEngineManager();
this.engine = new MiaoScriptEngine(manager, "nashorn");
this.engine.put("base", new Base());
Path bios = Paths.get(root, "bios.js");