feat: 优化版本更新检测流程
This commit is contained in:
@@ -6,6 +6,7 @@ plugins {
|
||||
|
||||
group = "cn.hamster3.mc.plugin"
|
||||
version = "1.3.3-SNAPSHOT"
|
||||
description = "叁只仓鼠的 Minecraft 插件开发通用工具包"
|
||||
|
||||
subprojects {
|
||||
apply {
|
||||
@@ -16,6 +17,7 @@ subprojects {
|
||||
|
||||
group = rootProject.group
|
||||
version = rootProject.version
|
||||
description = rootProject.description
|
||||
|
||||
repositories {
|
||||
maven("https://maven.airgame.net/maven-public")
|
||||
|
@@ -13,6 +13,7 @@ import cn.hamster3.mc.plugin.core.bukkit.page.handler.PageHandler;
|
||||
import cn.hamster3.mc.plugin.core.bukkit.page.listener.PageListener;
|
||||
import cn.hamster3.mc.plugin.core.bukkit.util.MinecraftVersion;
|
||||
import cn.hamster3.mc.plugin.core.common.api.CoreAPI;
|
||||
import cn.hamster3.mc.plugin.core.common.config.ConfigSection;
|
||||
import cn.hamster3.mc.plugin.core.common.config.YamlConfig;
|
||||
import cn.hamster3.mc.plugin.core.common.util.UpdateCheckUtils;
|
||||
import lombok.Getter;
|
||||
@@ -118,13 +119,17 @@ public class HamsterCorePlugin extends JavaPlugin {
|
||||
VaultAPI.reloadVaultHook();
|
||||
async(() -> {
|
||||
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
try (InputStream stream = plugin.getResource("update.yml")) {
|
||||
try (InputStream stream = plugin.getResource("plugin.yml")) {
|
||||
if (stream == null) {
|
||||
continue;
|
||||
}
|
||||
try (InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) {
|
||||
YamlConfig config = YamlConfig.load(reader);
|
||||
UpdateCheckUtils.checkUpdate(plugin.getName(), config);
|
||||
ConfigSection section = config.getSection("UPDATE_CHECKER");
|
||||
if (section == null) {
|
||||
continue;
|
||||
}
|
||||
UpdateCheckUtils.checkUpdate(plugin.getName(), section);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@@ -4,8 +4,15 @@ version: ${version}
|
||||
api-version: 1.13
|
||||
|
||||
author: MiniDay
|
||||
description: ${description}
|
||||
website: https://git.airgame.net/MiniDay/hamster-core
|
||||
description: 仓鼠核心:叁只仓鼠的 Minecraft 插件开发通用工具包
|
||||
|
||||
UPDATE_CHECKER:
|
||||
VERSION: ${version}
|
||||
CHECK_TYPE: GITEA_RELEASES
|
||||
GIT_BASE_URL: https://git.airgame.net
|
||||
GIT_REPO: MiniDay/hamster-core
|
||||
DOWNLOAD_URL: https://jenkins.airgame.net/job/opensource/job/hamster-core/
|
||||
|
||||
load: STARTUP
|
||||
|
||||
|
@@ -1,6 +0,0 @@
|
||||
version: ${version}
|
||||
CHECK_TYPE: GITEA_RELEASES
|
||||
GIT_BASE_URL: https://git.airgame.net
|
||||
GIT_REPO: MiniDay/hamster-core
|
||||
GIT_TOKEN: a44a69a4d1b8601bf6091403247759cd28764d5e
|
||||
DOWNLOAD_URL: https://jenkins.airgame.net/job/opensource/job/hamster-core/
|
@@ -2,6 +2,7 @@ package cn.hamster3.mc.plugin.core.bungee;
|
||||
|
||||
import cn.hamster3.mc.plugin.core.bungee.api.CoreBungeeAPI;
|
||||
import cn.hamster3.mc.plugin.core.common.api.CoreAPI;
|
||||
import cn.hamster3.mc.plugin.core.common.config.ConfigSection;
|
||||
import cn.hamster3.mc.plugin.core.common.config.YamlConfig;
|
||||
import cn.hamster3.mc.plugin.core.common.util.UpdateCheckUtils;
|
||||
import lombok.Getter;
|
||||
@@ -66,13 +67,17 @@ public class HamsterCorePlugin extends Plugin {
|
||||
|
||||
CoreAPI.getInstance().getExecutorService().submit(() -> {
|
||||
for (Plugin plugin : ProxyServer.getInstance().getPluginManager().getPlugins()) {
|
||||
try (InputStream stream = plugin.getResourceAsStream("update.yml")) {
|
||||
try (InputStream stream = plugin.getResourceAsStream("bungee.yml")) {
|
||||
if (stream == null) {
|
||||
continue;
|
||||
}
|
||||
try (InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) {
|
||||
YamlConfig config = YamlConfig.load(reader);
|
||||
UpdateCheckUtils.checkUpdate(plugin.getDescription().getName(), config);
|
||||
ConfigSection section = config.getSection("UPDATE_CHECKER");
|
||||
if (section == null) {
|
||||
continue;
|
||||
}
|
||||
UpdateCheckUtils.checkUpdate(plugin.getDescription().getName(), section);
|
||||
}
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
|
@@ -3,4 +3,12 @@ main: cn.hamster3.mc.plugin.core.bungee.HamsterCorePlugin
|
||||
version: ${version}
|
||||
|
||||
author: MiniDay
|
||||
description: 仓鼠核心:叁只仓鼠的 Minecraft 插件开发通用工具包
|
||||
description: ${description}
|
||||
website: https://git.airgame.net/MiniDay/hamster-core
|
||||
|
||||
UPDATE_CHECKER:
|
||||
VERSION: ${version}
|
||||
CHECK_TYPE: GITEA_RELEASES
|
||||
GIT_BASE_URL: https://git.airgame.net
|
||||
GIT_REPO: MiniDay/hamster-core
|
||||
DOWNLOAD_URL: https://jenkins.airgame.net/job/opensource/job/hamster-core/
|
||||
|
@@ -1,6 +0,0 @@
|
||||
version: ${version}
|
||||
CHECK_TYPE: GITEA_RELEASES
|
||||
GIT_BASE_URL: https://git.airgame.net
|
||||
GIT_REPO: MiniDay/hamster-core
|
||||
GIT_TOKEN: a44a69a4d1b8601bf6091403247759cd28764d5e
|
||||
DOWNLOAD_URL: https://jenkins.airgame.net/job/opensource/job/hamster-core/
|
@@ -18,7 +18,6 @@ import lombok.Getter;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -97,10 +96,8 @@ public class HamsterCorePlugin {
|
||||
try (InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) {
|
||||
YamlConfig config = YamlConfig.load(reader);
|
||||
UpdateCheckUtils.checkUpdate(pluginName, config);
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@@ -1,6 +1,5 @@
|
||||
version: ${version}
|
||||
VERSION: ${version}
|
||||
CHECK_TYPE: GITEA_RELEASES
|
||||
GIT_BASE_URL: https://git.airgame.net
|
||||
GIT_REPO: MiniDay/hamster-core
|
||||
GIT_TOKEN: a44a69a4d1b8601bf6091403247759cd28764d5e
|
||||
DOWNLOAD_URL: https://jenkins.airgame.net/job/opensource/job/hamster-core/
|
||||
|
Reference in New Issue
Block a user