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

View File

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