mirror of
https://e.coding.net/circlecloud/Yum.git
synced 2024-11-22 14:28:46 +00:00
添加fdel可以同时删除插件和数据文件...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
parent
c84655ddc6
commit
8f5d39ead0
4
pom.xml
4
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>1.9.5</version>
|
<version>1.9.5.1</version>
|
||||||
<name>Yum</name>
|
<name>Yum</name>
|
||||||
<description>Minecraft 服务器插件管理系统</description>
|
<description>Minecraft 服务器插件管理系统</description>
|
||||||
<build>
|
<build>
|
||||||
@ -55,7 +55,7 @@
|
|||||||
</build>
|
</build>
|
||||||
<properties>
|
<properties>
|
||||||
<jenkins.url>http://ci.citycraft.cn:8080</jenkins.url>
|
<jenkins.url>http://ci.citycraft.cn:8080</jenkins.url>
|
||||||
<update.description>&e添加yum info指令查看插件权限和注册命令...</update.description>
|
<update.description>&e添加fdel命令删除插件和数据文件...</update.description>
|
||||||
<env.BUILD_NUMBER>Debug</env.BUILD_NUMBER>
|
<env.BUILD_NUMBER>Debug</env.BUILD_NUMBER>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
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.api.YumAPI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插件删除命令类
|
||||||
|
*
|
||||||
|
* @author 蒋天蓓 2015年8月12日下午2:04:05
|
||||||
|
*/
|
||||||
|
public class CommandFullDelete extends BaseCommand {
|
||||||
|
Yum main;
|
||||||
|
|
||||||
|
public CommandFullDelete(final Yum main) {
|
||||||
|
super("fdel");
|
||||||
|
this.main = main;
|
||||||
|
setMinimumArguments(1);
|
||||||
|
setDescription("删除插件以及数据文件夹");
|
||||||
|
setPossibleArguments("<插件名称>");
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
if (plugin != null) {
|
||||||
|
final String version = plugin.getDescription().getVersion();
|
||||||
|
if (YumAPI.getPlugman().fullDeletePlugin(sender, plugin)) {
|
||||||
|
sender.sendMessage("§c删除: §a插件 §6" + pluginname + " §a版本 §d" + version + " §a已从服务器卸载并删除!");
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("§c删除: §c插件 " + pluginname + " 卸载或删除时发生错误 删除失败!");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("§c插件 " + pluginname + " 不存在或已卸载!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -12,6 +12,7 @@ public class YumCommand {
|
|||||||
cmdhandler.registerCommand(new CommandUpdate(yum));
|
cmdhandler.registerCommand(new CommandUpdate(yum));
|
||||||
cmdhandler.registerCommand(new CommandUpdateAll(yum));
|
cmdhandler.registerCommand(new CommandUpdateAll(yum));
|
||||||
cmdhandler.registerCommand(new CommandDelete(yum));
|
cmdhandler.registerCommand(new CommandDelete(yum));
|
||||||
|
cmdhandler.registerCommand(new CommandFullDelete(yum));
|
||||||
cmdhandler.registerCommand(new CommandInfo(yum));
|
cmdhandler.registerCommand(new CommandInfo(yum));
|
||||||
cmdhandler.registerCommand(new CommandRepo(yum));
|
cmdhandler.registerCommand(new CommandRepo(yum));
|
||||||
cmdhandler.registerCommand(new CommandReload(yum));
|
cmdhandler.registerCommand(new CommandReload(yum));
|
||||||
|
@ -28,10 +28,10 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
|||||||
import org.bukkit.plugin.PluginLoader;
|
import org.bukkit.plugin.PluginLoader;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.UnknownDependencyException;
|
import org.bukkit.plugin.UnknownDependencyException;
|
||||||
import org.bukkit.util.FileUtil;
|
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
|
|
||||||
|
import cn.citycraft.PluginHelper.utils.FileUtil;
|
||||||
import cn.citycraft.PluginHelper.utils.StringUtil;
|
import cn.citycraft.PluginHelper.utils.StringUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -128,6 +128,19 @@ public class PluginsManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除插件(包括数据)
|
||||||
|
*
|
||||||
|
* @param sender
|
||||||
|
* - 命令发送者
|
||||||
|
* @param plugin
|
||||||
|
* - 插件
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
public boolean fullDeletePlugin(final CommandSender sender, final Plugin plugin) {
|
||||||
|
return unload(sender, plugin) && getPluginFile(plugin).delete() && FileUtil.deleteDir(sender, plugin.getDataFolder());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得格式化的插件名称
|
* 获得格式化的插件名称
|
||||||
*
|
*
|
||||||
@ -617,7 +630,7 @@ public class PluginsManager {
|
|||||||
result = true;
|
result = true;
|
||||||
if (!unload(sender, name)) {
|
if (!unload(sender, name)) {
|
||||||
sender.sendMessage("§6升级: §d开始安装 §b" + name + " §d插件!");
|
sender.sendMessage("§6升级: §d开始安装 §b" + name + " §d插件!");
|
||||||
FileUtil.copy(file, new File(Bukkit.getUpdateFolderFile().getParentFile(), File.separatorChar + file.getName()));
|
FileUtil.copyFile(file, new File(Bukkit.getUpdateFolderFile().getParentFile(), File.separatorChar + file.getName()));
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage("§6升级: §a开始升级 §b" + name + " §a插件!");
|
sender.sendMessage("§6升级: §a开始升级 §b" + name + " §a插件!");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user