MVdWUpdater 是一款用于帮助 Spigot 服务器管理员安全更新付费插件的工具。它通过官方 API 直接下载已购买的插件资源,避免了从非官方渠道获取文件的安全风险,并支持双因素认证(2FA)登录。
本插件旨在让 Spigot 用户能够安全地更新其付费插件,而无需开发者将插件上传至不安全的下载位置。
plugins 文件夹。plugins/MVdWUpdater 目录。credentials.yml 文件,并按以下格式填写您的 SpigotMC 账户信息:## ---------------------------------------- #
## SpigotMC.org 账户凭据
## 请在此 yaml 文件中输入您的 SpigotMC.org 账户信息,
## 然后重启插件。插件将为您登录并存储会话 Cookie。
## ---------------------------------------- #
# 请勿编辑 config 版本号!
config: 2
# 输入您的 SpigotMC.org 用户名
username: ''
# 输入对应的密码
password: ''
# 如果您启用了双因素认证 (2FA),请在此输入 2FA 密钥
# 更多信息请查看插件主页
2fasecret: ''本插件为开发者提供了用于集成自动更新的 API。
重要版本规范:
主版本.次版本.修订版(例如 1.0.0)。这同时适用于您插件 plugin.yml 中的版本号以及您在 Spigot 资源页面上发布的更新描述中的版本号。 b 以表示测试版(例如 1.0.0b)。这同样适用于上述两处版本号。0 时,该版本将被视为 Alpha 版本。这也适用于上述两处版本号。softdepend 依赖本插件。相关开发链接:
基础示例:
MVdWUpdater updater = (MVdWUpdater) Bukkit.getPluginManager().getPlugin("MVdWUpdater");
if (updater.hasBought(updater.getSpigotUser(), RESOURCEID)) {
updater.updatePlugin(plugin, RESOURCEID, UpdateMethod.INSTALL_ON_RESTART, updater.getSpigotUser());
}高级示例(主版本不同时不更新):
try {
MVdWUpdater updater = (MVdWUpdater) Bukkit.getPluginManager().getPlugin("MVdWUpdater");
if (updater.hasBought(updater.getSpigotUser(), resourceId)) {
SendConsole.info("已接入 MVdWUpdater!");
List<Resource> premiums = updater.getPurchasedResources(updater.getSpigotUser());
for (Resource premium : premiums) {
if (premium.getResourceId() == resourceId) {
// 找到对应资源ID
SendConsole.info("正在检查 " + plugin.getName() + " 的更新...");
// 比较版本
Version currentPluginVersion = new Version(plugin.getDescription().getVersion());
Version newPluginVersion = new Version(updater.getResourceVersionString(resourceId));
if (currentPluginVersion.compare(newPluginVersion) == 1) {
SendConsole.info("发现 '" + plugin.getName() + "' 的可用更新");
// 如果更新是主版本更新,则不自动更新
if (currentPluginVersion.getMajor() != newPluginVersion.getMajor()){
SendConsole.info("此更新为主版本更新!需要手动更新!");
return;
}
SendConsole.info("获取下载链接...");
Resource premiumResource = updater.getSpigotSiteAPI().getResourceManager()
.getResourceById(premium.getResourceId(),updater.getSpigotUser());
// 将插件下载到更新文件夹
File pluginFile = null;
try {
pluginFile = new File(URLDecoder.decode(
plugin.getClass().getProtectionDomain().getCodeSource().getLocation().getPath(),
"UTF-8"));
} catch (UnsupportedEncodingException e) {
}
File outputFile = null;
try{
outputFile = new File(Bukkit.getUpdateFolderFile(), pluginFile.getName());
}catch (Exception ex){
}
if (pluginFile != null && outputFile != null) {
SendConsole.info("正在下载 '" + plugin.getName() + "' ...");
premiumResource.downloadResource(updater.getSpigotUser(), outputFile);
SendConsole.info(plugin.getName() + " 的新更新已准备就绪,将在下次重启时安装!");
}
}
break;
}
}
setUpdated(true);
}
} catch (Exception e) {
e.printStackTrace();
}仓库配置:
<repository>
<id>public</id>
<name>Public Repositories</name>
<url>http://repo.mvdw-software.be/content/groups/public/</url>
</repository>依赖项配置:
<dependency>
<groupId>be.maximvdw</groupId>
<artifactId>MVdWUpdater</artifactId>
<version>1.2.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>友情链接: 网易我的世界 | 泰拉瑞亚 | ocent云计算 | 米饭Minecraft插件文档 | 友链合作
历史访问人次:3,042,836 | 今日访问人次:26,964 | 昨日访问人次:20,728
独立 IP:7,465 | 最近24小时独立访客:24,108
Copyright © 2019-2026 我的世界服务器列表站. All rights reserved.
❤ Powered by GermMC 京ICP备17023959号-6