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
3f52c0462a
commit
e403b13659
@ -19,9 +19,11 @@ import cn.citycraft.Yum.Yum;
|
||||
* @author 蒋天蓓 2015年8月12日下午2:04:05
|
||||
*/
|
||||
public class CommandRm extends BaseCommand {
|
||||
Yum plugin;
|
||||
|
||||
public CommandRm(final Yum main) {
|
||||
super();
|
||||
plugin = main;
|
||||
setMinimumArguments(1);
|
||||
setDescription("删除文件夹(服务器JAR为根目录)");
|
||||
setPossibleArguments("<文件相对目录>");
|
||||
@ -38,9 +40,11 @@ public class CommandRm extends BaseCommand {
|
||||
sendMessage(sender, "§d路径 §e" + file.getAbsolutePath() + " §c是一个文件 请使用file delete!");
|
||||
return;
|
||||
}
|
||||
if (file.getAbsolutePath().toLowerCase().endsWith("plugins") || file.getAbsolutePath().toLowerCase().endsWith("world")) {
|
||||
sendMessage(sender, "§d路径 §e" + file.getAbsolutePath() + " §c不允许被删除!");
|
||||
return;
|
||||
for (final String name : plugin.config.getStringList("blacklist")) {
|
||||
if (file.getAbsolutePath().toLowerCase().endsWith(name)) {
|
||||
sendMessage(sender, "§d路径 §e" + file.getAbsolutePath() + " §c不允许被删除!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (file.listFiles().length != 0 && !(args.length > 1 && args[1].equalsIgnoreCase("-rf"))) {
|
||||
sendMessage(sender, "§d目录 §e" + file.getAbsolutePath() + " §c不为空!");
|
||||
|
@ -6,7 +6,7 @@ import cn.citycraft.Yum.Yum;
|
||||
public class FileCommand {
|
||||
public FileCommand(final Yum yum) {
|
||||
final HandlerSubCommand cmdhandler = new HandlerSubCommand(yum, "file");
|
||||
cmdhandler.setAllCommandOnlyConsole(yum.config.getBoolean("onlyCommandConsole", false));
|
||||
cmdhandler.setAllCommandOnlyConsole(yum.config.getBoolean("onlyFileCommandConsole", true));
|
||||
cmdhandler.registerCommand(new CommandDownLoad(yum));
|
||||
cmdhandler.registerCommand(new CommandDelete(yum));
|
||||
cmdhandler.registerCommand(new CommandRm(yum));
|
||||
|
@ -1,3 +1,9 @@
|
||||
Version: 1.0
|
||||
Version: 1.2
|
||||
#是否只允许控制台执行插件命令
|
||||
onlyCommandConsole: false
|
||||
onlyCommandConsole: false
|
||||
#是否只允许控制台执行插件文件命令
|
||||
onlyFileCommandConsole: true
|
||||
#禁止rm -rf的文件夹列表
|
||||
blacklist:
|
||||
- 'plugins'
|
||||
- 'worlds'
|
@ -12,8 +12,8 @@ commands:
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
file:
|
||||
description: MC文件管理命令
|
||||
usage: §6使用§a/yum help§6查看帮助!
|
||||
permission: yum.use
|
||||
usage: §6使用§a/file help§6查看帮助!
|
||||
permission: file.use
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
permissions:
|
||||
yum.use:
|
||||
|
Loading…
Reference in New Issue
Block a user