优化自动检查更新时间控制
Java CI-CD with Maven / build (push) Successful in 10m5s Details

This commit is contained in:
zhangyuheng 2024-05-08 11:38:41 +08:00
parent d881574a5a
commit d9a14af021
3 changed files with 9 additions and 7 deletions

View File

@ -37,7 +37,7 @@ jobs:
- name: "Release"
uses: https://ssl.lunadeer.cn:14446/zhangyuheng/release-action@main
with:
note: "带 `original-` 前缀的文件无法用于运行,请下载不带此前缀的版本。"
note: " - 带 `original-` 前缀的文件无法用于运行,请下载不带此前缀的版本。"
files: |-
staging/*.jar
api_key: '${{secrets.RELEASE_TOKEN}}'

View File

@ -6,7 +6,7 @@
<groupId>cn.lunadeer</groupId>
<artifactId>Dominion</artifactId>
<version>1.22.1-beta</version>
<version>1.22.2-beta</version>
<packaging>jar</packaging>
<name>Dominion</name>

View File

@ -12,6 +12,7 @@ import java.io.File;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.file.Files;
import java.util.Random;
import java.util.concurrent.TimeUnit;
public class GiteaReleaseCheck {
@ -30,11 +31,12 @@ public class GiteaReleaseCheck {
this.current_version = plugin.getPluginMeta().getVersion();
// 异步每12小时检查一次更新
plugin.getServer().getAsyncScheduler().runAtFixedRate(plugin, (instance) -> {
getLatestRelease();
if (auto_update) {
downloadUpdate();
}
}, 10, 60 * 60 * 12, TimeUnit.SECONDS);
getLatestRelease();
if (auto_update) {
downloadUpdate();
}
}, 10 + new Random().nextInt(10), 60 * 60 * 12 + new Random().nextInt(60),
TimeUnit.SECONDS);
}
public void enableAutoUpdate() {