mirror of
https://github.com/CarmJos/UserPrefix.git
synced 2024-09-19 20:15:47 +00:00
[2.4.0] 添加自动检查更新机制,并允许开关。
This commit is contained in:
parent
5df6e1fe34
commit
99c577c361
@ -1,5 +1,7 @@
|
|||||||
![BANNER](.documentation/images/banner.png)
|
![BANNER](.documentation/images/banner.png)
|
||||||
|
|
||||||
|
README LANGUAGES [ [中文](README.md) | [**English**](README-en.md) ]
|
||||||
|
|
||||||
# UserPrefix Plugin
|
# UserPrefix Plugin
|
||||||
|
|
||||||
[![CodeFactor](https://www.codefactor.io/repository/github/carmjos/userprefix/badge?s=b76fec1f64726b5f19989aace6adb5f85fdab840)](https://www.codefactor.io/repository/github/carmjos/userprefix)
|
[![CodeFactor](https://www.codefactor.io/repository/github/carmjos/userprefix/badge?s=b76fec1f64726b5f19989aace6adb5f85fdab840)](https://www.codefactor.io/repository/github/carmjos/userprefix)
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
![BANNER](.documentation/images/banner.png)
|
![BANNER](.documentation/images/banner.png)
|
||||||
|
|
||||||
|
README LANGUAGES [ [**中文**](README.md) | [English](README-en.md) ]
|
||||||
|
|
||||||
# 用户前缀系统插件
|
# 用户前缀系统插件
|
||||||
|
|
||||||
[![CodeFactor](https://www.codefactor.io/repository/github/carmjos/userprefix/badge?s=b76fec1f64726b5f19989aace6adb5f85fdab840)](https://www.codefactor.io/repository/github/carmjos/userprefix)
|
[![CodeFactor](https://www.codefactor.io/repository/github/carmjos/userprefix/badge?s=b76fec1f64726b5f19989aace6adb5f85fdab840)](https://www.codefactor.io/repository/github/carmjos/userprefix)
|
||||||
@ -13,8 +15,6 @@
|
|||||||
|
|
||||||
本插件基于Spigot实现,**理论上支持全版本**。
|
本插件基于Spigot实现,**理论上支持全版本**。
|
||||||
|
|
||||||
The **English version** of the introduction is [here](README-en.md).
|
|
||||||
|
|
||||||
> 本插件已在 [MCBBS](https://www.mcbbs.net/forum.php?mod=viewthread&tid=1261503) 与 [SpigotMC](https://www.spigotmc.org/resources/userprefix-hex-color-support-all-version.96277/) 上发布。
|
> 本插件已在 [MCBBS](https://www.mcbbs.net/forum.php?mod=viewthread&tid=1261503) 与 [SpigotMC](https://www.spigotmc.org/resources/userprefix-hex-color-support-all-version.96277/) 上发布。
|
||||||
|
|
||||||
## 示例
|
## 示例
|
||||||
|
18
pom.xml
18
pom.xml
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<groupId>cc.carm.plugin</groupId>
|
<groupId>cc.carm.plugin</groupId>
|
||||||
<artifactId>userprefix</artifactId>
|
<artifactId>userprefix</artifactId>
|
||||||
<version>2.3.3</version>
|
<version>2.4.0</version>
|
||||||
|
|
||||||
<name>UserPrefix</name>
|
<name>UserPrefix</name>
|
||||||
<description>轻便、高效、实时的用户前缀系统。</description>
|
<description>轻便、高效、实时的用户前缀系统。</description>
|
||||||
@ -127,6 +127,13 @@
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cc.carm.lib</groupId>
|
||||||
|
<artifactId>githubreleases4j</artifactId>
|
||||||
|
<version>1.3.1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
@ -209,9 +216,16 @@
|
|||||||
<relocations>
|
<relocations>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>org.bstats</pattern>
|
<pattern>org.bstats</pattern>
|
||||||
<!-- Replace this with your package! -->
|
|
||||||
<shadedPattern>cc.carm.plugin.userprefix.bstats</shadedPattern>
|
<shadedPattern>cc.carm.plugin.userprefix.bstats</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>cc.carm.lib.githubreleases4j</pattern>
|
||||||
|
<shadedPattern>cc.carm.plugin.userprefix.lib.github</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>org.json</pattern>
|
||||||
|
<shadedPattern>cc.carm.plugin.userprefix.lib.json</shadedPattern>
|
||||||
|
</relocation>
|
||||||
</relocations>
|
</relocations>
|
||||||
<filters>
|
<filters>
|
||||||
<filter>
|
<filter>
|
||||||
|
@ -3,6 +3,7 @@ package cc.carm.plugin.userprefix;
|
|||||||
import cc.carm.plugin.userprefix.command.UserPrefixAdminCommand;
|
import cc.carm.plugin.userprefix.command.UserPrefixAdminCommand;
|
||||||
import cc.carm.plugin.userprefix.command.UserPrefixCommand;
|
import cc.carm.plugin.userprefix.command.UserPrefixCommand;
|
||||||
import cc.carm.plugin.userprefix.configuration.PluginConfig;
|
import cc.carm.plugin.userprefix.configuration.PluginConfig;
|
||||||
|
import cc.carm.plugin.userprefix.hooker.UpdateChecker;
|
||||||
import cc.carm.plugin.userprefix.hooker.UserPrefixExpansion;
|
import cc.carm.plugin.userprefix.hooker.UserPrefixExpansion;
|
||||||
import cc.carm.plugin.userprefix.listener.ChatListener;
|
import cc.carm.plugin.userprefix.listener.ChatListener;
|
||||||
import cc.carm.plugin.userprefix.listener.UserListener;
|
import cc.carm.plugin.userprefix.listener.UserListener;
|
||||||
@ -72,6 +73,13 @@ public class Main extends JavaPlugin {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (PluginConfig.CHECK_UPDATE.get()) {
|
||||||
|
log("开始检查更新...");
|
||||||
|
UpdateChecker.checkUpdate(getDescription().getVersion());
|
||||||
|
} else {
|
||||||
|
log("已禁用检查更新,跳过。");
|
||||||
|
}
|
||||||
|
|
||||||
log("加载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
|
log("加载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
|
||||||
|
|
||||||
showAD();
|
showAD();
|
||||||
|
@ -13,6 +13,8 @@ public class PluginConfig {
|
|||||||
|
|
||||||
public static ConfigValue<Boolean> METRICS = new ConfigValue<>("metrics", Boolean.class, true);
|
public static ConfigValue<Boolean> METRICS = new ConfigValue<>("metrics", Boolean.class, true);
|
||||||
|
|
||||||
|
public static final ConfigValue<Boolean> CHECK_UPDATE = new ConfigValue<>("check-update", Boolean.class, true);
|
||||||
|
|
||||||
public static class CustomStorage {
|
public static class CustomStorage {
|
||||||
|
|
||||||
public static ConfigValue<Boolean> ENABLE = new ConfigValue<>("custom-storage.enable", Boolean.class, false);
|
public static ConfigValue<Boolean> ENABLE = new ConfigValue<>("custom-storage.enable", Boolean.class, false);
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package cc.carm.plugin.userprefix.hooker;
|
||||||
|
|
||||||
|
import cc.carm.lib.githubreleases4j.GithubReleases4J;
|
||||||
|
import cc.carm.plugin.userprefix.Main;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
public class UpdateChecker {
|
||||||
|
|
||||||
|
public static void checkUpdate(String currentVersion) {
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
String downloadURL = GithubReleases4J.getReleasesURL("CarmJos", "UserPrefix");
|
||||||
|
Integer behindVersions = GithubReleases4J.getVersionBehind(
|
||||||
|
"CarmJos", "UserPrefix", currentVersion
|
||||||
|
);
|
||||||
|
|
||||||
|
if (behindVersions == null) {
|
||||||
|
Main.error("检查更新失败,请您定期查看插件是否更新,避免安全问题。");
|
||||||
|
Main.error("下载地址 " + downloadURL);
|
||||||
|
} else if (behindVersions == 0) {
|
||||||
|
Main.log("检查完成,当前已是最新版本。");
|
||||||
|
} else if (behindVersions > 0) {
|
||||||
|
Main.log("发现新版本! 目前已落后 " + behindVersions + " 个版本。");
|
||||||
|
Main.log("最新版下载地址 " + downloadURL);
|
||||||
|
} else {
|
||||||
|
Main.error("检查更新失败! 当前版本未知,请您使用原生版本以避免安全问题。");
|
||||||
|
Main.error("最新版下载地址 " + downloadURL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskAsynchronously(Main.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -7,6 +7,11 @@ debug: false
|
|||||||
# 当然,您也可以选择在这里关闭,或在plugins/bStats下的配置文件中关闭。
|
# 当然,您也可以选择在这里关闭,或在plugins/bStats下的配置文件中关闭。
|
||||||
metrics: true
|
metrics: true
|
||||||
|
|
||||||
|
# 检查更新设定
|
||||||
|
# 该选项用于插件判断是否要检查更新,若您不希望插件检查更新并提示您,可以选择关闭。
|
||||||
|
# 检查更新为异步操作,绝不会影响性能与使用体验。
|
||||||
|
check-update: true
|
||||||
|
|
||||||
custom-storage:
|
custom-storage:
|
||||||
# 自定义存储位置
|
# 自定义存储位置
|
||||||
# 默认存储位置为 “插件文件夹”/prefixes
|
# 默认存储位置为 “插件文件夹”/prefixes
|
||||||
|
@ -4,6 +4,9 @@ debug: false #DEBUG OUT PUT
|
|||||||
|
|
||||||
metrics: true #Metrics stats (to help developer know the stats)
|
metrics: true #Metrics stats (to help developer know the stats)
|
||||||
|
|
||||||
|
# Auto check the updates.
|
||||||
|
check-update: true
|
||||||
|
|
||||||
custom-storage:
|
custom-storage:
|
||||||
# Custom storage location
|
# Custom storage location
|
||||||
# default location is "./prefixes"
|
# default location is "./prefixes"
|
||||||
|
Loading…
Reference in New Issue
Block a user