feat: 优化版本更新检测流程

This commit is contained in:
2024-03-19 16:31:38 +08:00
parent 7285f1b3e2
commit 98300804fe
9 changed files with 35 additions and 24 deletions

View File

@@ -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();

View File

@@ -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

View File

@@ -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/