async install plugin and fix install command...

This commit is contained in:
502647092 2015-08-22 16:40:38 +08:00
parent 755d49dc3b
commit d53a27fb40
2 changed files with 24 additions and 13 deletions

View File

@ -33,13 +33,18 @@ public class CommandInstall extends BaseCommand {
}; };
@Override @Override
public void execute(CommandSender sender, String label, String[] args) throws CommandException { public void execute(final CommandSender sender, String label, String[] args) throws CommandException {
String pluginname = args[0]; final String pluginname = args[0];
Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin(pluginname); Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin(pluginname);
if (plugin != null) { if (plugin == null) {
if (yum.download.run(sender, pluginname)) { Bukkit.getScheduler().runTaskAsynchronously(yum, new Runnable() {
sender.sendMessage(PluginsManager.load(pluginname)); @Override
} public void run() {
if (yum.download.run(sender, pluginname)) {
sender.sendMessage(PluginsManager.load(pluginname));
}
}
});
} else { } else {
sender.sendMessage("§c插件已安装在服务器 需要更新请使用yum update " + pluginname + "!"); sender.sendMessage("§c插件已安装在服务器 需要更新请使用yum update " + pluginname + "!");
} }

View File

@ -31,15 +31,21 @@ public class CommandUpdate extends BaseCommand {
}; };
@Override @Override
public void execute(CommandSender sender, String label, String[] args) throws CommandException { public void execute(final CommandSender sender, String label, String[] args) throws CommandException {
String pluginname = args[0]; final String pluginname = args[0];
Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin(pluginname); final Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin(pluginname);
sender.sendMessage("§a开始更新插件: " + pluginname); sender.sendMessage("§a开始更新插件: " + pluginname);
if (plugin != null) { if (plugin != null) {
sender.sendMessage(PluginsManager.unload(plugin)); Bukkit.getScheduler().runTaskAsynchronously(yum, new Runnable() {
if (yum.download.run(sender, pluginname)) { @Override
sender.sendMessage(PluginsManager.load(pluginname)); public void run() {
} sender.sendMessage(PluginsManager.unload(plugin));
PluginsManager.getPluginFile(plugin).delete();
if (yum.download.run(sender, pluginname)) {
sender.sendMessage(PluginsManager.load(pluginname));
}
}
});
} else { } else {
sender.sendMessage("§c插件未安装或已卸载 需要安装请使用yum install " + pluginname + "!"); sender.sendMessage("§c插件未安装或已卸载 需要安装请使用yum install " + pluginname + "!");
} }