mirror of
https://github.com/CarmJos/UltraDepository.git
synced 2026-06-04 16:48:21 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8f500e3ff0 | |||
| baeee39d07 | |||
| af82d64ab1 | |||
| 5d057d2e8e |
@@ -15,7 +15,7 @@
|
|||||||
<groupId>cc.carm.plugin</groupId>
|
<groupId>cc.carm.plugin</groupId>
|
||||||
<artifactId>ultradepository</artifactId>
|
<artifactId>ultradepository</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>1.3.4</version>
|
<version>1.3.6</version>
|
||||||
|
|
||||||
<name>UltraDepository</name>
|
<name>UltraDepository</name>
|
||||||
<description>超级仓库插件,支持设定不同物品的存储仓库。</description>
|
<description>超级仓库插件,支持设定不同物品的存储仓库。</description>
|
||||||
@@ -119,7 +119,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<artifactId>githubreleases4j</artifactId>
|
<artifactId>githubreleases4j</artifactId>
|
||||||
<version>1.2.0</version>
|
<version>1.3.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|||||||
@@ -1,42 +1,31 @@
|
|||||||
package cc.carm.plugin.ultradepository.hooker;
|
package cc.carm.plugin.ultradepository.hooker;
|
||||||
|
|
||||||
import cc.carm.lib.githubreleases4j.GithubRelease;
|
|
||||||
import cc.carm.lib.githubreleases4j.GithubReleases4J;
|
import cc.carm.lib.githubreleases4j.GithubReleases4J;
|
||||||
import cc.carm.plugin.ultradepository.UltraDepository;
|
import cc.carm.plugin.ultradepository.UltraDepository;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class UpdateChecker {
|
public class UpdateChecker {
|
||||||
|
|
||||||
public static void checkUpdate(UltraDepository plugin) {
|
public static void checkUpdate(UltraDepository plugin) {
|
||||||
plugin.getScheduler().runAsync(() -> {
|
plugin.getScheduler().runAsync(() -> {
|
||||||
|
|
||||||
try {
|
Integer behindVersions = GithubReleases4J.getVersionBehind(
|
||||||
|
"CarmJos", "UltraDepository",
|
||||||
|
plugin.getDescription().getVersion()
|
||||||
|
);
|
||||||
|
|
||||||
List<GithubRelease> releases = GithubReleases4J.listReleases("CarmJos", "UltraDepository");
|
String downloadURL = GithubReleases4J.getReleasesURL("CarmJos", "UltraDepository");
|
||||||
if (releases.isEmpty()) throw new NullPointerException(); // 无法获取更新
|
|
||||||
|
|
||||||
String currentVersion = plugin.getDescription().getVersion();
|
if (behindVersions == null) {
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
for (GithubRelease release : releases) {
|
|
||||||
if (release.getTagName().equalsIgnoreCase(currentVersion)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i > 0) {
|
|
||||||
GithubRelease latestRelease = releases.get(0);
|
|
||||||
plugin.log("检查更新完成,当前已落后 " + i + " 个版本,最新版本为 &6&l" + latestRelease.getTagName() + " &r。");
|
|
||||||
plugin.log("最新版本下载地址&e " + latestRelease.getHTMLUrl());
|
|
||||||
} else {
|
|
||||||
plugin.log("检查更新完成,当前已是最新版本。");
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception exception) {
|
|
||||||
plugin.error("检查更新失败,请您定期查看插件是否更新,避免安全问题。");
|
plugin.error("检查更新失败,请您定期查看插件是否更新,避免安全问题。");
|
||||||
plugin.error("插件下载地址&e https://github.com/CarmJos/UltraDepository/releases");
|
plugin.error("下载地址 " + downloadURL);
|
||||||
|
} else if (behindVersions == 0) {
|
||||||
|
plugin.error("检查完成,当前已是最新版本。");
|
||||||
|
} else if (behindVersions > 0) {
|
||||||
|
plugin.error("发现新版本! 目前已落后 " + behindVersions + " 个版本。");
|
||||||
|
plugin.error("最新版下载地址 " + downloadURL);
|
||||||
|
} else {
|
||||||
|
plugin.error("检查更新失败! 当前版本未知,请您使用原生版本以避免安全问题。");
|
||||||
|
plugin.error("最新版下载地址 " + downloadURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user