mirror of
https://e.coding.net/circlecloud/Yum.git
synced 2024-11-22 14:28:46 +00:00
修复检查可更新插件功能导致全局更新失效问题...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
parent
557a15e246
commit
4480b0fb3d
11
pom.xml
11
pom.xml
@ -3,7 +3,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>cn.citycraft</groupId>
|
<groupId>cn.citycraft</groupId>
|
||||||
<artifactId>Yum</artifactId>
|
<artifactId>Yum</artifactId>
|
||||||
<version>2.0.1</version>
|
<version>2.0.2</version>
|
||||||
<name>Yum</name>
|
<name>Yum</name>
|
||||||
<description>Minecraft 服务器插件管理系统</description>
|
<description>Minecraft 服务器插件管理系统</description>
|
||||||
<build>
|
<build>
|
||||||
@ -57,10 +57,9 @@
|
|||||||
<jenkins.url>http://hs.yumc.pw:8080</jenkins.url>
|
<jenkins.url>http://hs.yumc.pw:8080</jenkins.url>
|
||||||
<update.description>&a全新 2.0 版本 震撼发布...</update.description>
|
<update.description>&a全新 2.0 版本 震撼发布...</update.description>
|
||||||
<update.changes>
|
<update.changes>
|
||||||
&b2.0.1 &6- &c插件在upgrade时自动重命名为原有名称...
|
&b2.0.2 &6- &c修复检查可更新插件功能导致全局更新失效问题...;
|
||||||
&b2.0 &6- &a精简大量代码...
|
&b &6- &d新增全局更新限制 无法同时进行 防止错误...;
|
||||||
&a 服务器启动后自动检查可更新插件...
|
&b2.0.1 &6- &c插件在upgrade时自动重命名为原有名称...;
|
||||||
&a 优化检测流程...
|
|
||||||
</update.changes>
|
</update.changes>
|
||||||
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
|
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
@ -80,7 +79,7 @@
|
|||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<version>1.8.8-R0.1-SNAPSHOT</version>
|
<version>1.9-R0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.citycraft</groupId>
|
<groupId>cn.citycraft</groupId>
|
||||||
|
@ -6,6 +6,7 @@ package cn.citycraft.Yum;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import cn.citycraft.CommonData.UpdatePlugin;
|
||||||
import cn.citycraft.PluginHelper.config.FileConfig;
|
import cn.citycraft.PluginHelper.config.FileConfig;
|
||||||
import cn.citycraft.PluginHelper.utils.VersionChecker;
|
import cn.citycraft.PluginHelper.utils.VersionChecker;
|
||||||
import cn.citycraft.Yum.api.YumAPI;
|
import cn.citycraft.Yum.api.YumAPI;
|
||||||
@ -34,5 +35,7 @@ public class Yum extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
config = new FileConfig(this);
|
config = new FileConfig(this);
|
||||||
|
// 初始化更新列
|
||||||
|
UpdatePlugin.getUpdateList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import java.io.File;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -28,6 +27,7 @@ public class YumAPI {
|
|||||||
private static Plugin main;
|
private static Plugin main;
|
||||||
private static PluginsManager plugman;
|
private static PluginsManager plugman;
|
||||||
private static RepositoryManager repo;
|
private static RepositoryManager repo;
|
||||||
|
private static boolean runlock = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化Yum管理中心
|
* 初始化Yum管理中心
|
||||||
@ -85,16 +85,9 @@ public class YumAPI {
|
|||||||
for (final Entry<String, Plugin> updateplugin : UpdatePlugin.getUpdateList().entrySet()) {
|
for (final Entry<String, Plugin> updateplugin : UpdatePlugin.getUpdateList().entrySet()) {
|
||||||
ulist.add(updateplugin.getValue());
|
ulist.add(updateplugin.getValue());
|
||||||
}
|
}
|
||||||
UpdatePlugin.clearList();
|
|
||||||
} catch (final Exception | Error e) {
|
} catch (final Exception | Error e) {
|
||||||
try {
|
|
||||||
final Map<Plugin, String> updatelist = UpdatePlugin.getList();
|
|
||||||
ulist.addAll(updatelist.keySet());
|
|
||||||
UpdatePlugin.getList().clear();
|
|
||||||
} catch (final Exception | Error e2) {
|
|
||||||
sender.sendMessage("§4错误: §c无法检索全体更新列表!");
|
sender.sendMessage("§4错误: §c无法检索全体更新列表!");
|
||||||
sender.sendMessage("§4异常: §c" + e2.getMessage());
|
sender.sendMessage("§4异常: §c" + e.getMessage());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ulist;
|
return ulist;
|
||||||
}
|
}
|
||||||
@ -246,17 +239,30 @@ public class YumAPI {
|
|||||||
main.getServer().getScheduler().runTaskAsynchronously(main, new Runnable() {
|
main.getServer().getScheduler().runTaskAsynchronously(main, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if (runlock) {
|
||||||
|
sender.sendMessage("§d一键更新: §c一键更新运行中 请稍候重试...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
runlock = true;
|
||||||
|
int failed = 0;
|
||||||
final List<Plugin> ulist = getUpdateList(sender);
|
final List<Plugin> ulist = getUpdateList(sender);
|
||||||
if (ulist.size() > 0) {
|
if (ulist.size() > 0) {
|
||||||
|
sender.sendMessage("§d开始更新服务器可更新插件");
|
||||||
for (final Plugin updateplugin : ulist) {
|
for (final Plugin updateplugin : ulist) {
|
||||||
sender.sendMessage("§d一键更新: §a开始更新" + updateplugin.getName() + "!");
|
sender.sendMessage("§d一键更新: §a开始更新" + updateplugin.getName() + "!");
|
||||||
updatefromyum(sender, updateplugin, null, true);
|
if (!updatefromyum(sender, updateplugin, null, true))
|
||||||
|
failed++;
|
||||||
|
}
|
||||||
|
if (failed != 0) {
|
||||||
|
sender.sendMessage("§d一键更新: §c升级过程中 §4" + failed + " §c个插件更新失败!");
|
||||||
}
|
}
|
||||||
sender.sendMessage("§d一键更新: §e已下载所有需要升级的插件到 服务器更新 文件夹");
|
sender.sendMessage("§d一键更新: §e已下载所有需要升级的插件到 服务器更新 文件夹");
|
||||||
sender.sendMessage("§d一键更新: §e插件将在重启后自动更新(或使用§b/yum upgrade§e直接升级)!");
|
sender.sendMessage("§d一键更新: §e插件将在重启后自动更新(或使用§b/yum upgrade§e直接升级)!");
|
||||||
|
updatecheck(sender);
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage("§6更新: §e未找到需要更新且可以用Yum处理的插件!");
|
sender.sendMessage("§6更新: §e未找到需要更新且可以用Yum处理的插件!");
|
||||||
}
|
}
|
||||||
|
runlock = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -329,6 +335,7 @@ public class YumAPI {
|
|||||||
sender.sendMessage("§6更新: §e已下载 " + plugin.getName() + " 插件到服务器更新文件夹");
|
sender.sendMessage("§6更新: §e已下载 " + plugin.getName() + " 插件到服务器更新文件夹");
|
||||||
sender.sendMessage("§6更新: §e插件将在重启后自动更新(或使用§b/yum upgrade§e直接升级)!");
|
sender.sendMessage("§6更新: §e插件将在重启后自动更新(或使用§b/yum upgrade§e直接升级)!");
|
||||||
}
|
}
|
||||||
|
UpdatePlugin.getUpdateList().remove(plugin.getName());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -8,6 +8,9 @@ import java.util.Map;
|
|||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.permissions.Permission;
|
import org.bukkit.permissions.Permission;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
@ -30,7 +33,7 @@ import cn.citycraft.Yum.manager.RepositoryManager;
|
|||||||
* @since 2016年1月9日 上午10:02:24
|
* @since 2016年1月9日 上午10:02:24
|
||||||
* @author 喵♂呜
|
* @author 喵♂呜
|
||||||
*/
|
*/
|
||||||
public class YumCommand implements HandlerCommands {
|
public class YumCommand implements HandlerCommands, Listener {
|
||||||
Yum main;
|
Yum main;
|
||||||
RepositoryManager repo;
|
RepositoryManager repo;
|
||||||
PluginsManager plugman;
|
PluginsManager plugman;
|
||||||
@ -39,6 +42,7 @@ public class YumCommand implements HandlerCommands {
|
|||||||
main = yum;
|
main = yum;
|
||||||
repo = YumAPI.getRepo();
|
repo = YumAPI.getRepo();
|
||||||
plugman = YumAPI.getPlugman();
|
plugman = YumAPI.getPlugman();
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, yum);
|
||||||
final InvokeSubCommand cmdhandler = new InvokeSubCommand(yum, "yum");
|
final InvokeSubCommand cmdhandler = new InvokeSubCommand(yum, "yum");
|
||||||
cmdhandler.setAllCommandOnlyConsole(yum.config.getBoolean("onlyCommandConsole", false));
|
cmdhandler.setAllCommandOnlyConsole(yum.config.getBoolean("onlyCommandConsole", false));
|
||||||
cmdhandler.registerCommands(this);
|
cmdhandler.registerCommands(this);
|
||||||
@ -174,6 +178,13 @@ public class YumCommand implements HandlerCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onAdminJoin(final PlayerJoinEvent e) {
|
||||||
|
if (e.getPlayer().isOp()) {
|
||||||
|
YumAPI.updatecheck(e.getPlayer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@HandlerCommand(name = "reload", aliases = { "re" }, minimumArguments = 1, description = "重载插件", possibleArguments = "<插件名称|all|*>")
|
@HandlerCommand(name = "reload", aliases = { "re" }, minimumArguments = 1, description = "重载插件", possibleArguments = "<插件名称|all|*>")
|
||||||
public void reload(final InvokeCommandEvent e) {
|
public void reload(final InvokeCommandEvent e) {
|
||||||
final CommandSender sender = e.getSender();
|
final CommandSender sender = e.getSender();
|
||||||
@ -297,12 +308,10 @@ public class YumCommand implements HandlerCommands {
|
|||||||
|
|
||||||
@HandlerCommand(name = "updateall", aliases = { "ua" }, description = "更新所有可更新插件")
|
@HandlerCommand(name = "updateall", aliases = { "ua" }, description = "更新所有可更新插件")
|
||||||
public void updateall(final InvokeCommandEvent e) {
|
public void updateall(final InvokeCommandEvent e) {
|
||||||
final CommandSender sender = e.getSender();
|
|
||||||
sender.sendMessage("§d开始更新服务器可更新插件");
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(main, new Runnable() {
|
Bukkit.getScheduler().runTaskAsynchronously(main, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
YumAPI.updateall(sender);
|
YumAPI.updateall(e.getSender());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user