mirror of
https://e.coding.net/circlecloud/Yum.git
synced 2024-12-23 05:08:47 +00:00
更新命令处理...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
parent
281e09b496
commit
857cda6fe5
@ -17,6 +17,7 @@ import cn.citycraft.Yum.commands.CommandReload;
|
||||
import cn.citycraft.Yum.commands.CommandRepo;
|
||||
import cn.citycraft.Yum.commands.CommandUnload;
|
||||
import cn.citycraft.Yum.commands.CommandUpdate;
|
||||
import cn.citycraft.Yum.commands.CommandUpdateAll;
|
||||
import cn.citycraft.Yum.commands.CommandUpgrade;
|
||||
import cn.citycraft.Yum.manager.YumManager;
|
||||
|
||||
@ -30,10 +31,11 @@ public class Yum extends JavaPlugin {
|
||||
public YumManager yumgr;
|
||||
|
||||
public void initCommands() {
|
||||
final HandlerSubCommand cmdhandler = new HandlerSubCommand(this);
|
||||
final HandlerSubCommand cmdhandler = new HandlerSubCommand(this, "yum");
|
||||
cmdhandler.registerCommand(new CommandList(this));
|
||||
cmdhandler.registerCommand(new CommandInstall(this));
|
||||
cmdhandler.registerCommand(new CommandUpdate(this));
|
||||
cmdhandler.registerCommand(new CommandUpdateAll(this));
|
||||
cmdhandler.registerCommand(new CommandDelete(this));
|
||||
cmdhandler.registerCommand(new CommandInfo(this));
|
||||
cmdhandler.registerCommand(new CommandRepo(this));
|
||||
@ -41,8 +43,6 @@ public class Yum extends JavaPlugin {
|
||||
cmdhandler.registerCommand(new CommandLoad(this));
|
||||
cmdhandler.registerCommand(new CommandUnload(this));
|
||||
cmdhandler.registerCommand(new CommandUpgrade(this));
|
||||
this.getCommand("yum").setExecutor(cmdhandler);
|
||||
this.getCommand("yum").setTabCompleter(cmdhandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,7 +25,7 @@ public class CommandDelete extends BaseCommand {
|
||||
* @param name
|
||||
*/
|
||||
public CommandDelete(final Yum main) {
|
||||
super("delete", "remove");
|
||||
super("remove");
|
||||
this.main = main;
|
||||
setMinimumArguments(1);
|
||||
setDescription("删除插件");
|
||||
|
@ -30,7 +30,7 @@ public class CommandInfo extends BaseCommand {
|
||||
* @param name
|
||||
*/
|
||||
public CommandInfo(final Yum main) {
|
||||
super("info");
|
||||
super();
|
||||
this.main = main;
|
||||
setMinimumArguments(1);
|
||||
setDescription("查看插件详情");
|
||||
|
@ -29,7 +29,7 @@ public class CommandInstall extends BaseCommand {
|
||||
* @param name
|
||||
*/
|
||||
public CommandInstall(final Yum main) {
|
||||
super("install");
|
||||
super();
|
||||
this.main = main;
|
||||
setMinimumArguments(1);
|
||||
setDescription("安装插件");
|
||||
|
@ -25,7 +25,7 @@ public class CommandList extends BaseCommand {
|
||||
* @param name
|
||||
*/
|
||||
public CommandList(final Yum main) {
|
||||
super("list");
|
||||
super();
|
||||
this.main = main;
|
||||
setDescription("列出已安装插件列表");
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class CommandLoad extends BaseCommand {
|
||||
* @param name
|
||||
*/
|
||||
public CommandLoad(final Yum main) {
|
||||
super("load");
|
||||
super();
|
||||
this.main = main;
|
||||
setMinimumArguments(1);
|
||||
setDescription("载入插件");
|
||||
|
@ -25,7 +25,7 @@ public class CommandReload extends BaseCommand {
|
||||
* @param name
|
||||
*/
|
||||
public CommandReload(final Yum main) {
|
||||
super("reload");
|
||||
super();
|
||||
this.main = main;
|
||||
setMinimumArguments(1);
|
||||
setDescription("重载插件");
|
||||
|
@ -28,7 +28,7 @@ public class CommandRepo extends BaseCommand {
|
||||
* @param name
|
||||
*/
|
||||
public CommandRepo(final Yum main) {
|
||||
super("repo");
|
||||
super();
|
||||
this.main = main;
|
||||
setMinimumArguments(1);
|
||||
setDescription("插件源命令");
|
||||
|
@ -25,7 +25,7 @@ public class CommandUnload extends BaseCommand {
|
||||
* @param name
|
||||
*/
|
||||
public CommandUnload(final Yum main) {
|
||||
super("unload");
|
||||
super();
|
||||
this.main = main;
|
||||
setMinimumArguments(1);
|
||||
setDescription("卸载插件");
|
||||
|
@ -23,7 +23,7 @@ public class CommandUpdate extends BaseCommand {
|
||||
* @param name
|
||||
*/
|
||||
public CommandUpdate(final Yum main) {
|
||||
super("update");
|
||||
super();
|
||||
this.main = main;
|
||||
setMinimumArguments(1);
|
||||
setDescription("更新插件");
|
||||
|
@ -0,0 +1,51 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.Yum.commands;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
import cn.citycraft.Yum.Yum;
|
||||
import cn.citycraft.Yum.manager.YumManager;
|
||||
|
||||
/**
|
||||
* @author 蒋天蓓 2015年8月12日下午2:04:05
|
||||
*/
|
||||
public class CommandUpdateAll extends BaseCommand {
|
||||
Yum main;
|
||||
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public CommandUpdateAll(final Yum main) {
|
||||
super();
|
||||
this.main = main;
|
||||
setDescription("更新所有可更新插件");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final String pluginname = args[0];
|
||||
final Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin(pluginname);
|
||||
sender.sendMessage("§a开始更新服务器可更新插件");
|
||||
if (plugin != null) {
|
||||
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]);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
sender.sendMessage("§c插件" + pluginname + "未安装或已卸载 需要安装请使用/yum install " + pluginname + "!");
|
||||
}
|
||||
};
|
||||
}
|
@ -23,7 +23,7 @@ public class CommandUpgrade extends BaseCommand {
|
||||
* @param name
|
||||
*/
|
||||
public CommandUpgrade(final Yum main) {
|
||||
super("upgrade");
|
||||
super();
|
||||
this.main = main;
|
||||
setDescription("升级插件");
|
||||
setPossibleArguments("[插件名称]");
|
||||
|
Loading…
Reference in New Issue
Block a user