From e403b13659e736ff0084de37248b904b71b9dd9e Mon Sep 17 00:00:00 2001 From: 502647092 Date: Fri, 18 Dec 2015 17:31:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=98=B2=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E9=BB=91=E5=90=8D=E5=8D=95...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 502647092 --- .../java/cn/citycraft/Yum/file/commands/CommandRm.java | 10 +++++++--- .../cn/citycraft/Yum/file/commands/FileCommand.java | 2 +- src/main/resources/config.yml | 10 ++++++++-- src/main/resources/plugin.yml | 4 ++-- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/main/java/cn/citycraft/Yum/file/commands/CommandRm.java b/src/main/java/cn/citycraft/Yum/file/commands/CommandRm.java index b6c2e9a..8c7b7cb 100644 --- a/src/main/java/cn/citycraft/Yum/file/commands/CommandRm.java +++ b/src/main/java/cn/citycraft/Yum/file/commands/CommandRm.java @@ -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不为空!"); diff --git a/src/main/java/cn/citycraft/Yum/file/commands/FileCommand.java b/src/main/java/cn/citycraft/Yum/file/commands/FileCommand.java index 2246397..16b833a 100644 --- a/src/main/java/cn/citycraft/Yum/file/commands/FileCommand.java +++ b/src/main/java/cn/citycraft/Yum/file/commands/FileCommand.java @@ -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)); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 702b5c8..8014aee 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,3 +1,9 @@ -Version: 1.0 +Version: 1.2 #是否只允许控制台执行插件命令 -onlyCommandConsole: false \ No newline at end of file +onlyCommandConsole: false +#是否只允许控制台执行插件文件命令 +onlyFileCommandConsole: true +#禁止rm -rf的文件夹列表 +blacklist: +- 'plugins' +- 'worlds' \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index a2ef2b6..bf9d6ec 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -12,8 +12,8 @@ commands: permission-message: §c你没有 的权限来执行此命令! file: description: MC文件管理命令 - usage: §6使用§a/yum help§6查看帮助! - permission: yum.use + usage: §6使用§a/file help§6查看帮助! + permission: file.use permission-message: §c你没有 的权限来执行此命令! permissions: yum.use: