mirror of
https://e.coding.net/circlecloud/Yum.git
synced 2024-11-22 14:28:46 +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
|
* @author 蒋天蓓 2015年8月12日下午2:04:05
|
||||||
*/
|
*/
|
||||||
public class CommandRm extends BaseCommand {
|
public class CommandRm extends BaseCommand {
|
||||||
|
Yum plugin;
|
||||||
|
|
||||||
public CommandRm(final Yum main) {
|
public CommandRm(final Yum main) {
|
||||||
super();
|
super();
|
||||||
|
plugin = main;
|
||||||
setMinimumArguments(1);
|
setMinimumArguments(1);
|
||||||
setDescription("删除文件夹(服务器JAR为根目录)");
|
setDescription("删除文件夹(服务器JAR为根目录)");
|
||||||
setPossibleArguments("<文件相对目录>");
|
setPossibleArguments("<文件相对目录>");
|
||||||
@ -38,10 +40,12 @@ public class CommandRm extends BaseCommand {
|
|||||||
sendMessage(sender, "§d路径 §e" + file.getAbsolutePath() + " §c是一个文件 请使用file delete!");
|
sendMessage(sender, "§d路径 §e" + file.getAbsolutePath() + " §c是一个文件 请使用file delete!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (file.getAbsolutePath().toLowerCase().endsWith("plugins") || file.getAbsolutePath().toLowerCase().endsWith("world")) {
|
for (final String name : plugin.config.getStringList("blacklist")) {
|
||||||
|
if (file.getAbsolutePath().toLowerCase().endsWith(name)) {
|
||||||
sendMessage(sender, "§d路径 §e" + file.getAbsolutePath() + " §c不允许被删除!");
|
sendMessage(sender, "§d路径 §e" + file.getAbsolutePath() + " §c不允许被删除!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (file.listFiles().length != 0 && !(args.length > 1 && args[1].equalsIgnoreCase("-rf"))) {
|
if (file.listFiles().length != 0 && !(args.length > 1 && args[1].equalsIgnoreCase("-rf"))) {
|
||||||
sendMessage(sender, "§d目录 §e" + file.getAbsolutePath() + " §c不为空!");
|
sendMessage(sender, "§d目录 §e" + file.getAbsolutePath() + " §c不为空!");
|
||||||
sendMessage(sender, "§c请使用 §a/file rm " + fpath + " -rf §c强行删除!");
|
sendMessage(sender, "§c请使用 §a/file rm " + fpath + " -rf §c强行删除!");
|
||||||
|
@ -6,7 +6,7 @@ import cn.citycraft.Yum.Yum;
|
|||||||
public class FileCommand {
|
public class FileCommand {
|
||||||
public FileCommand(final Yum yum) {
|
public FileCommand(final Yum yum) {
|
||||||
final HandlerSubCommand cmdhandler = new HandlerSubCommand(yum, "file");
|
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 CommandDownLoad(yum));
|
||||||
cmdhandler.registerCommand(new CommandDelete(yum));
|
cmdhandler.registerCommand(new CommandDelete(yum));
|
||||||
cmdhandler.registerCommand(new CommandRm(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> 的权限来执行此命令!
|
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||||
file:
|
file:
|
||||||
description: MC文件管理命令
|
description: MC文件管理命令
|
||||||
usage: §6使用§a/yum help§6查看帮助!
|
usage: §6使用§a/file help§6查看帮助!
|
||||||
permission: yum.use
|
permission: file.use
|
||||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||||
permissions:
|
permissions:
|
||||||
yum.use:
|
yum.use:
|
||||||
|
Loading…
Reference in New Issue
Block a user