feat: 自动检测 Jenkins 更新

This commit is contained in:
2024-03-17 00:32:59 +08:00
parent 0fd72513be
commit 21a91a8405
4 changed files with 56 additions and 56 deletions

View File

@@ -95,11 +95,11 @@ public class HamsterCorePlugin extends Plugin {
try (InputStreamReader reader = new InputStreamReader(resource, StandardCharsets.UTF_8)) {
YamlConfig jenkinsConfig = YamlConfig.load(reader);
String jobUrl = jenkinsConfig.getString("JOB_URL");
if (jobUrl == null || jobUrl.equalsIgnoreCase("NONE")) {
if (jobUrl == null || jobUrl.equalsIgnoreCase("DEV")) {
continue;
}
String buildNumberString = jenkinsConfig.getString("BUILD_NUMBER");
if (buildNumberString == null || buildNumberString.equalsIgnoreCase("NONE")) {
if (buildNumberString == null || buildNumberString.equalsIgnoreCase("DEV")) {
continue;
}
int lastStableBuild = JenkinsUtils.getLastStableBuild(jobUrl, null, null);
@@ -109,12 +109,9 @@ public class HamsterCorePlugin extends Plugin {
continue;
}
String pluginName = plugin.getDescription().getName();
sender.sendMessage(TextComponent.fromLegacyText(
String.format("§a检测到服务器内安装的 %s 插件有 %d 个版本更新", pluginName, version)
));
sender.sendMessage(TextComponent.fromLegacyText(
String.format("§b下载链接: &b&n&l%s", jobUrl)
));
sender.sendMessage(TextComponent.fromLegacyText(String.format(
"§a检测到插件 %s 落后 %d 个版本更新, 下载链接: §n§l%s", pluginName, version, jobUrl
)));
} catch (IOException ignored) {
}
}