添加文件重命名命令 修复下载命令错误...

Signed-off-by: 502647092 <jtb1@163.com>
dev
502647092 2015-12-21 14:59:36 +08:00
parent e403b13659
commit b715f8dfe8
5 changed files with 47 additions and 7 deletions

View File

@ -18,11 +18,8 @@ import cn.citycraft.Yum.Yum;
* @author 20158122:04:05
*/
public class CommandDelete extends BaseCommand {
Yum main;
public CommandDelete(final Yum main) {
super("del");
this.main = main;
setMinimumArguments(1);
setDescription("删除文件(服务器JAR为根目录)");
setPossibleArguments("<文件相对目录>");

View File

@ -45,8 +45,6 @@ public class CommandDownLoad extends BaseCommand {
} else {
file = new File(Bukkit.getUpdateFolderFile(), dl.getFileName(urlstr));
}
if (args.length == 1) {
dl.run(sender, urlstr, file);
}
dl.run(sender, urlstr, file);
}
}

View File

@ -20,7 +20,7 @@ import cn.citycraft.Yum.Yum;
public class CommandLs extends BaseCommand {
public CommandLs(final Yum main) {
super();
super("l");
setDescription("列出当前目录(服务器JAR为根目录)");
setPossibleArguments("<相对目录>");
}

View File

@ -0,0 +1,44 @@
/**
*
*/
package cn.citycraft.Yum.file.commands;
import java.io.File;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import cn.citycraft.PluginHelper.commands.BaseCommand;
import cn.citycraft.Yum.Yum;
/**
*
*
* @author 20158122:04:05
*/
public class CommandRename extends BaseCommand {
public CommandRename(final Yum main) {
super("rn");
setMinimumArguments(2);
setDescription("重命名文件(服务器JAR为根目录)");
setPossibleArguments("<文件相对目录> <文件名称>");
}
@Override
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
final String fpath = args[0];
final File file = new File(fpath);
if (!file.exists()) {
sendMessage(sender, "§c文件 " + file.getAbsolutePath() + " 不存在!");
} else {
try {
final File newFile = new File(file.getParentFile(), args[1]);
file.renameTo(newFile);
sendMessage(sender, "§a文件 §e" + file.getAbsolutePath() + " §a重命名为 §d" + newFile.getAbsolutePath());
} catch (final Exception e) {
sendMessage(sender, "§c文件 §e" + file.getAbsolutePath() + " §c重命名失败: " + e.getMessage());
}
}
}
}

View File

@ -9,6 +9,7 @@ public class FileCommand {
cmdhandler.setAllCommandOnlyConsole(yum.config.getBoolean("onlyFileCommandConsole", true));
cmdhandler.registerCommand(new CommandDownLoad(yum));
cmdhandler.registerCommand(new CommandDelete(yum));
cmdhandler.registerCommand(new CommandRename(yum));
cmdhandler.registerCommand(new CommandRm(yum));
cmdhandler.registerCommand(new CommandLs(yum));
}