2015-08-22 07:13:59 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
package cn.citycraft.Yum.commands;
|
|
|
|
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.command.CommandException;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
|
|
|
|
import cn.citycraft.Yum.Yum;
|
2015-09-01 11:09:29 +00:00
|
|
|
import cn.citycraft.Yum.manager.YumManager;
|
2015-08-22 07:13:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author 蒋天蓓 2015年8月12日下午2:04:05
|
|
|
|
*/
|
|
|
|
public class CommandUpdate extends BaseCommand {
|
2015-08-31 13:28:02 +00:00
|
|
|
Yum main;
|
2015-08-22 07:13:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param name
|
|
|
|
*/
|
2015-09-24 11:02:44 +00:00
|
|
|
public CommandUpdate(final Yum main) {
|
2015-09-22 12:21:55 +00:00
|
|
|
super("update", "更新插件");
|
2015-08-31 13:28:02 +00:00
|
|
|
this.main = main;
|
2015-09-22 12:03:59 +00:00
|
|
|
setMinimumArguments(1);
|
|
|
|
setPossibleArguments("<插件名称> [插件版本]");
|
2015-08-22 07:13:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-24 11:02:44 +00:00
|
|
|
public void execute(final CommandSender sender, final String label, final String[] args) throws CommandException {
|
2015-08-22 08:40:38 +00:00
|
|
|
final String pluginname = args[0];
|
|
|
|
final Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin(pluginname);
|
2015-08-22 07:13:59 +00:00
|
|
|
sender.sendMessage("§a开始更新插件: " + pluginname);
|
2015-09-24 11:02:44 +00:00
|
|
|
if (plugin != null) {
|
2015-09-26 14:58:00 +00:00
|
|
|
Bukkit.getScheduler().runTaskAsynchronously(main, new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
if (args.length < 2) {
|
|
|
|
YumManager.update(sender, plugin);
|
|
|
|
} else {
|
|
|
|
YumManager.update(sender, plugin, args[1]);
|
|
|
|
}
|
2015-09-24 11:02:44 +00:00
|
|
|
}
|
2015-08-22 08:40:38 +00:00
|
|
|
});
|
2015-09-24 11:02:44 +00:00
|
|
|
} else {
|
2015-08-22 07:13:59 +00:00
|
|
|
sender.sendMessage("§c插件未安装或已卸载 需要安装请使用yum install " + pluginname + "!");
|
2015-09-24 11:02:44 +00:00
|
|
|
}
|
2015-08-23 02:10:13 +00:00
|
|
|
};
|
2015-08-22 07:13:59 +00:00
|
|
|
}
|