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