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;
|
||||||
@ -29,132 +30,139 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
|
|
||||||
public class Main extends JavaPlugin {
|
public class Main extends JavaPlugin {
|
||||||
|
|
||||||
private static Main instance;
|
private static Main instance;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
instance = this;
|
instance = this;
|
||||||
showPluginName();
|
showPluginName();
|
||||||
log(getName() + " " + getDescription().getVersion() + " &7开始加载...");
|
log(getName() + " " + getDescription().getVersion() + " &7开始加载...");
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
log("加载配置文件...");
|
log("加载配置文件...");
|
||||||
ConfigManager.initConfig();
|
ConfigManager.initConfig();
|
||||||
PrefixManager.init();
|
PrefixManager.init();
|
||||||
|
|
||||||
log("注册指令...");
|
log("注册指令...");
|
||||||
registerCommand("UserPrefix", new UserPrefixCommand());
|
registerCommand("UserPrefix", new UserPrefixCommand());
|
||||||
registerCommand("UserPrefixAdmin", new UserPrefixAdminCommand());
|
registerCommand("UserPrefixAdmin", new UserPrefixAdminCommand());
|
||||||
|
|
||||||
log("注册监听器...");
|
log("注册监听器...");
|
||||||
regListener(new UserListener());
|
regListener(new UserListener());
|
||||||
regListener(new ChatListener());
|
regListener(new ChatListener());
|
||||||
ServiceManager.getService().getEventBus().subscribe(this, UserDataRecalculateEvent.class, UserNodeUpdateProcessor::process);
|
ServiceManager.getService().getEventBus().subscribe(this, UserDataRecalculateEvent.class, UserNodeUpdateProcessor::process);
|
||||||
|
|
||||||
if (MessageUtil.hasPlaceholderAPI()) {
|
if (MessageUtil.hasPlaceholderAPI()) {
|
||||||
log("注册变量...");
|
log("注册变量...");
|
||||||
new UserPrefixExpansion(getInstance()).register();
|
new UserPrefixExpansion(getInstance()).register();
|
||||||
} else {
|
} else {
|
||||||
log("未安装 PlaceholderAPI 不进行变量注册...");
|
log("未安装 PlaceholderAPI 不进行变量注册...");
|
||||||
log("若您想使用变量进行前缀的显示,请安装PlaceholderAPI!");
|
log("若您想使用变量进行前缀的显示,请安装PlaceholderAPI!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PluginConfig.METRICS.get()) {
|
if (PluginConfig.METRICS.get()) {
|
||||||
log("启用统计数据...");
|
log("启用统计数据...");
|
||||||
Metrics metrics = new Metrics(this, 13776);
|
Metrics metrics = new Metrics(this, 13776);
|
||||||
metrics.addCustomChart(new SingleLineChart("active_prefixes", () -> PrefixManager.getPrefixes().size()));
|
metrics.addCustomChart(new SingleLineChart("active_prefixes", () -> PrefixManager.getPrefixes().size()));
|
||||||
metrics.addCustomChart(new SimplePie("custom_storage", () -> PluginConfig.CustomStorage.ENABLE.get() ? "ENABLE" : "DISABLE"));
|
metrics.addCustomChart(new SimplePie("custom_storage", () -> PluginConfig.CustomStorage.ENABLE.get() ? "ENABLE" : "DISABLE"));
|
||||||
metrics.addCustomChart(new SimplePie("lp_version", () -> ServiceManager.getService().getPluginMetadata().getVersion()));
|
metrics.addCustomChart(new SimplePie("lp_version", () -> ServiceManager.getService().getPluginMetadata().getVersion()));
|
||||||
metrics.addCustomChart(new SimplePie("papi_version", () -> {
|
metrics.addCustomChart(new SimplePie("papi_version", () -> {
|
||||||
Plugin plugin = Bukkit.getPluginManager().getPlugin("PlaceholderAPI");
|
Plugin plugin = Bukkit.getPluginManager().getPlugin("PlaceholderAPI");
|
||||||
if (plugin == null) return "Not installed";
|
if (plugin == null) return "Not installed";
|
||||||
else return plugin.getDescription().getVersion();
|
else return plugin.getDescription().getVersion();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
log("加载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
|
if (PluginConfig.CHECK_UPDATE.get()) {
|
||||||
|
log("开始检查更新...");
|
||||||
|
UpdateChecker.checkUpdate(getDescription().getVersion());
|
||||||
|
} else {
|
||||||
|
log("已禁用检查更新,跳过。");
|
||||||
|
}
|
||||||
|
|
||||||
showAD();
|
log("加载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
|
||||||
|
|
||||||
if (Bukkit.getOnlinePlayers().size() > 0) {
|
showAD();
|
||||||
Bukkit.getOnlinePlayers().forEach(UserManager::initPlayer); // 适配热重载
|
|
||||||
}
|
if (Bukkit.getOnlinePlayers().size() > 0) {
|
||||||
|
Bukkit.getOnlinePlayers().forEach(UserManager::initPlayer); // 适配热重载
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
showPluginName();
|
showPluginName();
|
||||||
log(getName() + " " + getDescription().getVersion() + " 开始卸载...");
|
log(getName() + " " + getDescription().getVersion() + " 开始卸载...");
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
log("卸载监听器...");
|
log("卸载监听器...");
|
||||||
Bukkit.getServicesManager().unregisterAll(this);
|
Bukkit.getServicesManager().unregisterAll(this);
|
||||||
|
|
||||||
log("卸载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
|
log("卸载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
|
||||||
|
|
||||||
showAD();
|
showAD();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册监听器
|
* 注册监听器
|
||||||
*
|
*
|
||||||
* @param listener 监听器
|
* @param listener 监听器
|
||||||
*/
|
*/
|
||||||
public static void regListener(Listener listener) {
|
public static void regListener(Listener listener) {
|
||||||
Bukkit.getPluginManager().registerEvents(listener, getInstance());
|
Bukkit.getPluginManager().registerEvents(listener, getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(String message) {
|
public static void log(String message) {
|
||||||
Bukkit.getConsoleSender().sendMessage(ColorParser.parse("[" + getInstance().getName() + "] " + message));
|
Bukkit.getConsoleSender().sendMessage(ColorParser.parse("[" + getInstance().getName() + "] " + message));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void debug(String message) {
|
public static void debug(String message) {
|
||||||
if (PluginConfig.DEBUG.get()) {
|
if (PluginConfig.DEBUG.get()) {
|
||||||
log("[DEBUG] " + message);
|
log("[DEBUG] " + message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void error(String message) {
|
public static void error(String message) {
|
||||||
log("&c[ERROR] &r" + message);
|
log("&c[ERROR] &r" + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static JavaPlugin getInstance() {
|
public static JavaPlugin getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void registerCommand(String commandName,
|
public static void registerCommand(String commandName,
|
||||||
@NotNull CommandExecutor executor) {
|
@NotNull CommandExecutor executor) {
|
||||||
registerCommand(commandName, executor, null);
|
registerCommand(commandName, executor, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerCommand(String commandName,
|
public static void registerCommand(String commandName,
|
||||||
@NotNull CommandExecutor executor,
|
@NotNull CommandExecutor executor,
|
||||||
@Nullable TabCompleter tabCompleter) {
|
@Nullable TabCompleter tabCompleter) {
|
||||||
PluginCommand command = Bukkit.getPluginCommand(commandName);
|
PluginCommand command = Bukkit.getPluginCommand(commandName);
|
||||||
if (command == null) return;
|
if (command == null) return;
|
||||||
command.setExecutor(executor);
|
command.setExecutor(executor);
|
||||||
if (tabCompleter != null) command.setTabCompleter(tabCompleter);
|
if (tabCompleter != null) command.setTabCompleter(tabCompleter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showPluginName() {
|
private void showPluginName() {
|
||||||
log("&b _ _ &f _____ __ _ ");
|
log("&b _ _ &f _____ __ _ ");
|
||||||
log("&b| | | | &f| __ \\ / _|(_) ");
|
log("&b| | | | &f| __ \\ / _|(_) ");
|
||||||
log("&b| | | | ___ ___ _ __ &f| |__) |_ __ ___ | |_ _ __ __");
|
log("&b| | | | ___ ___ _ __ &f| |__) |_ __ ___ | |_ _ __ __");
|
||||||
log("&b| | | |/ __| / _ \\| '__|&f| ___/| '__|/ _ \\| _|| |\\ \\/ /");
|
log("&b| | | |/ __| / _ \\| '__|&f| ___/| '__|/ _ \\| _|| |\\ \\/ /");
|
||||||
log("&b| |__| |\\__ \\| __/| | &f| | | | | __/| | | | > < ");
|
log("&b| |__| |\\__ \\| __/| | &f| | | | | __/| | | | > < ");
|
||||||
log("&b \\____/ |___/ \\___||_| &f|_| |_| \\___||_| |_|/_/\\_\\");
|
log("&b \\____/ |___/ \\___||_| &f|_| |_| \\___||_| |_|/_/\\_\\");
|
||||||
log("&8 ");
|
log("&8 ");
|
||||||
log("&8> &f" + getDescription().getWebsite());
|
log("&8> &f" + getDescription().getWebsite());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showAD() {
|
private void showAD() {
|
||||||
log("&7感谢您使用 &3&lUserPrefix " + getDescription().getVersion() + "&7!");
|
log("&7感谢您使用 &3&lUserPrefix " + getDescription().getVersion() + "&7!");
|
||||||
log("&7本插件由 &b&lYourCraft &7提供长期支持与维护。");
|
log("&7本插件由 &b&lYourCraft &7提供长期支持与维护。");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,77 +9,79 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
public class PluginConfig {
|
public class PluginConfig {
|
||||||
|
|
||||||
public static ConfigValue<Boolean> DEBUG = new ConfigValue<>("debug", Boolean.class, false);
|
public static ConfigValue<Boolean> DEBUG = new ConfigValue<>("debug", Boolean.class, false);
|
||||||
|
|
||||||
public static ConfigValue<Boolean> METRICS = new ConfigValue<>("metrics", Boolean.class, true);
|
public static ConfigValue<Boolean> METRICS = new ConfigValue<>("metrics", Boolean.class, true);
|
||||||
|
|
||||||
public static class CustomStorage {
|
public static final ConfigValue<Boolean> CHECK_UPDATE = new ConfigValue<>("check-update", Boolean.class, true);
|
||||||
|
|
||||||
public static ConfigValue<Boolean> ENABLE = new ConfigValue<>("custom-storage.enable", Boolean.class, false);
|
public static class CustomStorage {
|
||||||
|
|
||||||
public static ConfigValue<String> PATH = new ConfigValue<>("custom-storage.path", String.class, "prefixes/");
|
public static ConfigValue<Boolean> ENABLE = new ConfigValue<>("custom-storage.enable", Boolean.class, false);
|
||||||
|
|
||||||
}
|
public static ConfigValue<String> PATH = new ConfigValue<>("custom-storage.path", String.class, "prefixes/");
|
||||||
|
|
||||||
public static class Functions {
|
}
|
||||||
|
|
||||||
public static ConfigValue<Boolean> NAME_PREFIX = new ConfigValue<>("functions.OnNamePrefix", Boolean.class, true);
|
public static class Functions {
|
||||||
public static ConfigValue<Boolean> AUTO_USE = new ConfigValue<>("functions.autoUsePrefix", Boolean.class, true);
|
|
||||||
|
|
||||||
public static class Chat {
|
public static ConfigValue<Boolean> NAME_PREFIX = new ConfigValue<>("functions.OnNamePrefix", Boolean.class, true);
|
||||||
|
public static ConfigValue<Boolean> AUTO_USE = new ConfigValue<>("functions.autoUsePrefix", Boolean.class, true);
|
||||||
|
|
||||||
public static ConfigValue<Boolean> ENABLE = new ConfigValue<>("functions.chat.enable", Boolean.class, false);
|
public static class Chat {
|
||||||
public static ConfigValue<String> FORMAT = new ConfigValue<>("functions.chat.format", String.class, "<%1$s> %2$s");
|
|
||||||
|
|
||||||
}
|
public static ConfigValue<Boolean> ENABLE = new ConfigValue<>("functions.chat.enable", Boolean.class, false);
|
||||||
|
public static ConfigValue<String> FORMAT = new ConfigValue<>("functions.chat.format", String.class, "<%1$s> %2$s");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class GUI {
|
}
|
||||||
|
|
||||||
public static ConfigValue<String> TITLE = new ConfigValue<>("GUI.title", String.class, "&f&l我的前缀 &8| 列表");
|
public static class GUI {
|
||||||
|
|
||||||
public static class Items {
|
public static ConfigValue<String> TITLE = new ConfigValue<>("GUI.title", String.class, "&f&l我的前缀 &8| 列表");
|
||||||
|
|
||||||
public static ConfigValue<ItemStack> NEXT_PAGE = new ConfigValue<>("GUI.items.next-page", ItemStack.class,
|
public static class Items {
|
||||||
new ItemStackFactory(Material.ARROW)
|
|
||||||
.setDisplayName("下一页")
|
|
||||||
.addLore("&7&o右键可前往最后一页哦")
|
|
||||||
.toItemStack()
|
|
||||||
);
|
|
||||||
public static ConfigValue<ItemStack> PREVIOUS_PAGE = new ConfigValue<>("GUI.items.previous-page", ItemStack.class,
|
|
||||||
new ItemStackFactory(Material.ARROW)
|
|
||||||
.setDisplayName("上一页")
|
|
||||||
.addLore("&7&o右键可前往第一页哦")
|
|
||||||
.toItemStack()
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
public static ConfigValue<ItemStack> NEXT_PAGE = new ConfigValue<>("GUI.items.next-page", ItemStack.class,
|
||||||
|
new ItemStackFactory(Material.ARROW)
|
||||||
|
.setDisplayName("下一页")
|
||||||
|
.addLore("&7&o右键可前往最后一页哦")
|
||||||
|
.toItemStack()
|
||||||
|
);
|
||||||
|
public static ConfigValue<ItemStack> PREVIOUS_PAGE = new ConfigValue<>("GUI.items.previous-page", ItemStack.class,
|
||||||
|
new ItemStackFactory(Material.ARROW)
|
||||||
|
.setDisplayName("上一页")
|
||||||
|
.addLore("&7&o右键可前往第一页哦")
|
||||||
|
.toItemStack()
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Messages {
|
}
|
||||||
|
|
||||||
public static ConfigMessageList SELECTED = new ConfigMessageList("selected");
|
public static class Messages {
|
||||||
public static ConfigMessageList EXPIRED = new ConfigMessageList("expired");
|
|
||||||
public static ConfigMessageList REMOVED = new ConfigMessageList("removed");
|
|
||||||
|
|
||||||
public static ConfigMessageList RELOAD = new ConfigMessageList("reload");
|
public static ConfigMessageList SELECTED = new ConfigMessageList("selected");
|
||||||
public static ConfigMessageList HELP = new ConfigMessageList("help");
|
public static ConfigMessageList EXPIRED = new ConfigMessageList("expired");
|
||||||
|
public static ConfigMessageList REMOVED = new ConfigMessageList("removed");
|
||||||
|
|
||||||
public static ConfigMessageList LIST_TITLE = new ConfigMessageList("list-title");
|
public static ConfigMessageList RELOAD = new ConfigMessageList("reload");
|
||||||
public static ConfigMessageList LIST_VALUE = new ConfigMessageList("list-value");
|
public static ConfigMessageList HELP = new ConfigMessageList("help");
|
||||||
|
|
||||||
}
|
public static ConfigMessageList LIST_TITLE = new ConfigMessageList("list-title");
|
||||||
|
public static ConfigMessageList LIST_VALUE = new ConfigMessageList("list-value");
|
||||||
|
|
||||||
public static class Sounds {
|
}
|
||||||
|
|
||||||
public static ConfigSound GUI_OPEN = new ConfigSound("Sounds.openGUI");
|
public static class Sounds {
|
||||||
public static ConfigSound GUI_CLICK = new ConfigSound("Sounds.guiClick");
|
|
||||||
public static ConfigSound PREFIX_CHANGE = new ConfigSound("Sounds.prefixChange");
|
|
||||||
public static ConfigSound PREFIX_EXPIRED = new ConfigSound("Sounds.prefixExpired");
|
|
||||||
|
|
||||||
}
|
public static ConfigSound GUI_OPEN = new ConfigSound("Sounds.openGUI");
|
||||||
|
public static ConfigSound GUI_CLICK = new ConfigSound("Sounds.guiClick");
|
||||||
|
public static ConfigSound PREFIX_CHANGE = new ConfigSound("Sounds.prefixChange");
|
||||||
|
public static ConfigSound PREFIX_EXPIRED = new ConfigSound("Sounds.prefixExpired");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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