feat: release 0.18.0 version
1. optimize load logic 2. add root change detach 3. add common softdepends Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
ce92ae9ec6
commit
91a87ab20e
20
pom.xml
20
pom.xml
@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>pw.yumc</groupId>
|
||||
<artifactId>MiaoScript</artifactId>
|
||||
<version>0.17.0</version>
|
||||
<version>0.18.0</version>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>502647092</id>
|
||||
@ -53,6 +53,10 @@
|
||||
<properties>
|
||||
<env.GIT_COMMIT>DEV</env.GIT_COMMIT>
|
||||
<update.changes>
|
||||
§622-02-16 §afeat: 优化 初始化逻辑 加快引擎加载速度;
|
||||
§afeat: 新增 root 目录变更检测 变更后重新生成缓存;
|
||||
§afeat: 添加常用库的软依赖;
|
||||
§622-01-01 §afeat: 兼容JDK17 更新Nashorn;
|
||||
§621-11-04 §afeat: 优化系统模块升级逻辑;
|
||||
§621-07-10 §afeat: 优化网络相关功能;
|
||||
§621-06-25 §afeat: 调整启动逻辑 兼容 Arclight;
|
||||
@ -168,10 +172,6 @@
|
||||
<id>yumc-repo</id>
|
||||
<url>${repo.url}/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sponge</id>
|
||||
<url>https://repo.spongepowered.org/maven/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
@ -190,7 +190,7 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.18</version>
|
||||
<version>1.18.22</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.kamranzafar</groupId>
|
||||
@ -212,18 +212,18 @@
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.16-R0.4-SNAPSHOT</version>
|
||||
<version>1.16-R0.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.nukkit</groupId>
|
||||
<artifactId>nukkit</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-websocket</artifactId>
|
||||
<version>5.2.6.RELEASE</version>
|
||||
<version>5.3.13</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -233,4 +233,4 @@
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
</project>
|
@ -13,12 +13,17 @@ import java.nio.file.Path;
|
||||
* Created on 2017/10/9 12:40.
|
||||
*/
|
||||
public class Base {
|
||||
public static final String VERSION = "0.18.0";
|
||||
private Object instance;
|
||||
|
||||
public Base(Object instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return Base.VERSION;
|
||||
}
|
||||
|
||||
public Class<?> getClass(String name) throws ClassNotFoundException {
|
||||
return Class.forName(name);
|
||||
}
|
||||
@ -39,10 +44,10 @@ public class Base {
|
||||
return new String(Files.readAllBytes(new File(path).toPath()), StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public void save(String path, String content) throws IOException {
|
||||
public Path save(String path, String content) throws IOException {
|
||||
File file = new File(path);
|
||||
file.getParentFile().mkdirs();
|
||||
Files.write(file.toPath(), content.getBytes(StandardCharsets.UTF_8));
|
||||
return Files.write(file.toPath(), content.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
public boolean move(String source, String target) {
|
||||
@ -54,8 +59,8 @@ public class Base {
|
||||
return delete(new File(path));
|
||||
}
|
||||
|
||||
public void delete(Path path) throws IOException {
|
||||
delete(path.toFile());
|
||||
public boolean delete(Path path) throws IOException {
|
||||
return delete(path.toFile());
|
||||
}
|
||||
|
||||
public boolean delete(File file) throws IOException {
|
||||
|
@ -9,12 +9,11 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
* @author 喵♂呜
|
||||
* @since 2016年8月29日 上午7:50:39
|
||||
*/
|
||||
public class MiaoScript extends JavaPlugin {
|
||||
public class MiaoScriptBukkit extends JavaPlugin {
|
||||
private ScriptEngine engine;
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public void onLoad() {
|
||||
public MiaoScriptBukkit() {
|
||||
ClassLoader origin = Thread.currentThread().getContextClassLoader();
|
||||
Thread.currentThread().setContextClassLoader(getClassLoader());
|
||||
engine = new ScriptEngine(getDataFolder().getCanonicalPath(), getLogger(), this);
|
||||
@ -22,6 +21,10 @@ public class MiaoScript extends JavaPlugin {
|
||||
engine.loadEngine();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
engine.enableEngine();
|
||||
@ -30,5 +33,6 @@ public class MiaoScript extends JavaPlugin {
|
||||
@Override
|
||||
public void onDisable() {
|
||||
engine.disableEngine();
|
||||
engine = null;
|
||||
}
|
||||
}
|
@ -12,14 +12,17 @@ import net.md_5.bungee.api.plugin.Plugin;
|
||||
public class MiaoScriptBungee extends Plugin {
|
||||
private ScriptEngine engine;
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public void onLoad() {
|
||||
public MiaoScriptBungee() {
|
||||
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
|
||||
engine = new ScriptEngine(getDataFolder().getCanonicalPath(), getLogger(), this);
|
||||
engine.loadEngine();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
engine.enableEngine();
|
||||
|
@ -112,11 +112,11 @@ public class MiaoScriptEngine implements ScriptEngine, Invocable {
|
||||
File libRootFile = new File(engineRoot, "lib");
|
||||
libRootFile.mkdirs();
|
||||
String libRoot = libRootFile.getCanonicalPath();
|
||||
downloadJar(libRoot, "org.openjdk.nashorn", "nashorn-core", "15.2");
|
||||
downloadJar(libRoot, "org.ow2.asm", "asm", "9.1");
|
||||
downloadJar(libRoot, "org.ow2.asm", "asm-commons", "9.1");
|
||||
downloadJar(libRoot, "org.ow2.asm", "asm-tree", "9.1");
|
||||
downloadJar(libRoot, "org.ow2.asm", "asm-util", "9.1");
|
||||
downloadJar(libRoot, "org.openjdk.nashorn", "nashorn-core", "15.3");
|
||||
downloadJar(libRoot, "org.ow2.asm", "asm", "9.2");
|
||||
downloadJar(libRoot, "org.ow2.asm", "asm-commons", "9.2");
|
||||
downloadJar(libRoot, "org.ow2.asm", "asm-tree", "9.2");
|
||||
downloadJar(libRoot, "org.ow2.asm", "asm-util", "9.2");
|
||||
this.createEngineByName("nashorn");
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ public class MiaoScriptEngine implements ScriptEngine, Invocable {
|
||||
|
||||
@SneakyThrows
|
||||
private void downloadJar(String engineRoot, String groupId, String artifactId, String version) {
|
||||
File lib = new File(engineRoot, artifactId + ".jar");
|
||||
File lib = new File(engineRoot, String.format("%s-%s.jar", artifactId, version));
|
||||
if (!lib.exists()) {
|
||||
Files.copy(new URL(MavenRepo +
|
||||
String.format("/%1$s/%2$s/%3$s/%2$s-%3$s.jar",
|
||||
|
@ -9,12 +9,15 @@ import lombok.SneakyThrows;
|
||||
public class MiaoScriptNukkit extends PluginBase {
|
||||
private ScriptEngine engine;
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public void onLoad() {
|
||||
public MiaoScriptNukkit() {
|
||||
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
|
||||
engine = new ScriptEngine(getDataFolder().getCanonicalPath(), getLogger(), this);
|
||||
engine.enableEngine();
|
||||
engine = new ScriptEngine(getDataFolder().getCanonicalPath(), super.getLogger(), this);
|
||||
engine.loadEngine();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,7 +1,7 @@
|
||||
package pw.yumc.MiaoScript;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import lombok.SneakyThrows;
|
||||
import org.slf4j.Logger;
|
||||
import org.spongepowered.api.config.ConfigDir;
|
||||
import org.spongepowered.api.event.Listener;
|
||||
@ -11,8 +11,7 @@ import org.spongepowered.api.event.game.state.GameStartingServerEvent;
|
||||
import org.spongepowered.api.event.game.state.GameStoppingServerEvent;
|
||||
import org.spongepowered.api.plugin.Plugin;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import lombok.SneakyThrows;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA
|
||||
@ -20,7 +19,7 @@ import lombok.SneakyThrows;
|
||||
* @author 喵♂呜
|
||||
* Created on 2017/10/25 20:35.
|
||||
*/
|
||||
@Plugin(id = "miaoscript", name = "MiaoScript", version = "1.0", authors = "MiaoWoo")
|
||||
@Plugin(id = "miaoscript", name = "MiaoScript", version = Base.VERSION, authors = "MiaoWoo")
|
||||
public class MiaoScriptSponge {
|
||||
private ScriptEngine engine;
|
||||
@Inject
|
||||
@ -55,6 +54,7 @@ public class MiaoScriptSponge {
|
||||
public void reload(GameReloadEvent event) {
|
||||
engine.disableEngine();
|
||||
engine = new ScriptEngine(pluginConfigDir.getCanonicalPath(), logger, this);
|
||||
engine.loadEngine();
|
||||
engine.enableEngine();
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ var global = this;
|
||||
/**
|
||||
* Init MiaoScriptEngine Runtime
|
||||
*/
|
||||
/*global base */
|
||||
/*global base ScriptEngineContextHolder*/
|
||||
(function () {
|
||||
var Files = Java.type('java.nio.file.Files')
|
||||
var Paths = Java.type('java.nio.file.Paths')
|
||||
|
@ -526,7 +526,12 @@
|
||||
require.clear = __DynamicClear__
|
||||
require.disable = __DynamicDisable__
|
||||
require.setUpgradeMode = __setUpgradeMode__
|
||||
require.core_modules = CoreModules
|
||||
require.internal = {
|
||||
coreModules: CoreModules,
|
||||
cacheModules: cacheModules,
|
||||
cacheModuleIds: cacheModuleIds,
|
||||
notFoundModules: notFoundModules,
|
||||
}
|
||||
return require
|
||||
}
|
||||
|
||||
@ -540,7 +545,7 @@
|
||||
var cacheModuleIdsFile = _canonical(new File(NODE_PATH, 'cacheModuleIds.json'))
|
||||
var localVersionLockFile = _canonical(new File(NODE_PATH, 'moduleVersionLock.json'))
|
||||
/**
|
||||
* @type {{[key:string]:{[key:string]:string}}} cacheModuleIds
|
||||
* @type {{[key:string]:{[key:string]:string}|string}} cacheModuleIds
|
||||
*/
|
||||
var cacheModuleIds = {}
|
||||
/**
|
||||
@ -559,10 +564,14 @@
|
||||
try {
|
||||
// @ts-ignore
|
||||
cacheModuleIds = JSON.parse(base.read(cacheModuleIdsFile))
|
||||
if (cacheModuleIds['@ccms-cache-module-root'] != NODE_PATH) {
|
||||
throw new Error('canonicalRoot Change ' + cacheModuleIds['@ccms-cache-module-root'] + ' to ' + NODE_PATH + ' Clear Cache!')
|
||||
}
|
||||
console.log('Read cacheModuleIds from file ' + cacheModuleIdsFile)
|
||||
} catch (error) {
|
||||
cacheModuleIds = {}
|
||||
console.log('Initialization new cacheModuleIds')
|
||||
cacheModuleIds['@ccms-cache-module-root'] = NODE_PATH
|
||||
console.log('Initialization new cacheModuleIds: ' + error)
|
||||
}
|
||||
try {
|
||||
ModulesVersionLock = JSON.parse(fetchContent('http://ms.yumc.pw/api/plugin/download/name/version_lock'))
|
||||
|
@ -1,12 +1,22 @@
|
||||
name: ${project.artifactId}
|
||||
description: ${project.description}
|
||||
main: ${project.groupId}.${project.artifactId}.${project.artifactId}
|
||||
main: ${project.groupId}.${project.artifactId}.${project.artifactId}Bukkit
|
||||
version: ${project.version}
|
||||
api-version: 1.13
|
||||
author: MiaoWoo
|
||||
website: ${ciManagement.url}
|
||||
load: STARTUP
|
||||
softdepend:
|
||||
- PlaceholderAPI
|
||||
- ProtocolLib
|
||||
- Vault
|
||||
- PlaceholderAPI
|
||||
- AttributePlus
|
||||
- PlayerPoints
|
||||
- CrazyCrates
|
||||
- ProtocolLib
|
||||
- DragonCore
|
||||
- MythicMobs
|
||||
- WorldGuard
|
||||
- Adyeshach
|
||||
- WorldEdit
|
||||
- SkillAPI
|
||||
- TradeMe
|
||||
- Chemdah
|
||||
- Vault
|
||||
|
Loading…
Reference in New Issue
Block a user