feat: 取消解压plugins 调整debug逻辑
This commit is contained in:
parent
b1f9f2987c
commit
8f2bc2cc3f
@ -8,7 +8,8 @@ var global = this;
|
||||
*/
|
||||
(function () {
|
||||
var loader;
|
||||
|
||||
var Files = Java.type("java.nio.file.Files");
|
||||
var Paths = Java.type("java.nio.file.Paths");
|
||||
boot = function (root, logger) {
|
||||
log = logger;
|
||||
// 开发环境下初始化
|
||||
@ -17,11 +18,14 @@ var global = this;
|
||||
logger.info('载入自定义 BIOS 文件 ' + __FILE__);
|
||||
global.debug = true;
|
||||
}
|
||||
if (Files.exists(Paths.get(root, "debug"))) {
|
||||
logger.info('已开启调试模式!');
|
||||
global.debug = true;
|
||||
}
|
||||
// 检查类加载器 防止找不到核心文件
|
||||
loader = checkClassLoader();
|
||||
// 解压文件到根目录 非调试模式直接从jar解压覆盖
|
||||
release(root, "[api|core|internal|modules]/.*", !global.debug);
|
||||
release(root, "plugins/.*");
|
||||
release(root, '(api|core|internal|modules)+/.*', !global.debug);
|
||||
load(root + '/core/init.js');
|
||||
try {
|
||||
init(root);
|
||||
@ -45,8 +49,6 @@ var global = this;
|
||||
}
|
||||
|
||||
function release(root, regex, replace) {
|
||||
var Files = Java.type("java.nio.file.Files");
|
||||
var Paths = Java.type("java.nio.file.Paths");
|
||||
var StandardCopyOption = Java.type("java.nio.file.StandardCopyOption");
|
||||
|
||||
var upath = pluginYml.getFile().substring(pluginYml.getFile().indexOf("/") + 1);
|
||||
@ -54,23 +56,23 @@ var global = this;
|
||||
if (!Files.exists(Paths.get(jarPath))) {
|
||||
jarPath = "/" + jarPath;
|
||||
}
|
||||
|
||||
try {
|
||||
var jar = new java.util.jar.JarFile(jarPath);
|
||||
var r = new RegExp(regex);// "[core|modules]/.*"
|
||||
jar.stream().forEach(function (entry) {
|
||||
var jar = new java.util.jar.JarFile(jarPath);
|
||||
var r = new RegExp(regex);// "[core|modules]/.*"
|
||||
jar.stream().forEach(function (entry) {
|
||||
try {
|
||||
if (!entry.isDirectory()) {
|
||||
if (r.test(entry.name)) {
|
||||
var path = Paths.get(root, entry.name);
|
||||
var parentFile = path.toFile().parentFile;
|
||||
if (!parentFile.exists()) {
|
||||
parentFile.mkdirs();
|
||||
if (!parentFile.exists()) { parentFile.mkdirs(); }
|
||||
if (!Files.exists(path) || replace) {
|
||||
Files.copy(loader.getResourceAsStream(entry.name), path, StandardCopyOption['REPLACE_EXISTING']);
|
||||
}
|
||||
Files.copy(classLoader.getResourceAsStream(entry.name), path, StandardCopyOption[replace ? 'REPLACE_EXISTING' : 'ATOMIC_MOVE']);
|
||||
}
|
||||
}
|
||||
})
|
||||
} catch (ex) {
|
||||
}
|
||||
} catch (ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
})
|
||||
}
|
||||
})();
|
Loading…
Reference in New Issue
Block a user