mirror of
https://e.coding.net/circlecloud/Yum.git
synced 2025-01-11 01:38:46 +00:00
添加文件重命名命令 修复下载命令错误...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
parent
e403b13659
commit
b715f8dfe8
@ -18,11 +18,8 @@ import cn.citycraft.Yum.Yum;
|
|||||||
* @author 蒋天蓓 2015年8月12日下午2:04:05
|
* @author 蒋天蓓 2015年8月12日下午2:04:05
|
||||||
*/
|
*/
|
||||||
public class CommandDelete extends BaseCommand {
|
public class CommandDelete extends BaseCommand {
|
||||||
Yum main;
|
|
||||||
|
|
||||||
public CommandDelete(final Yum main) {
|
public CommandDelete(final Yum main) {
|
||||||
super("del");
|
super("del");
|
||||||
this.main = main;
|
|
||||||
setMinimumArguments(1);
|
setMinimumArguments(1);
|
||||||
setDescription("删除文件(服务器JAR为根目录)");
|
setDescription("删除文件(服务器JAR为根目录)");
|
||||||
setPossibleArguments("<文件相对目录>");
|
setPossibleArguments("<文件相对目录>");
|
||||||
|
@ -45,8 +45,6 @@ public class CommandDownLoad extends BaseCommand {
|
|||||||
} else {
|
} else {
|
||||||
file = new File(Bukkit.getUpdateFolderFile(), dl.getFileName(urlstr));
|
file = new File(Bukkit.getUpdateFolderFile(), dl.getFileName(urlstr));
|
||||||
}
|
}
|
||||||
if (args.length == 1) {
|
|
||||||
dl.run(sender, urlstr, file);
|
dl.run(sender, urlstr, file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -20,7 +20,7 @@ import cn.citycraft.Yum.Yum;
|
|||||||
public class CommandLs extends BaseCommand {
|
public class CommandLs extends BaseCommand {
|
||||||
|
|
||||||
public CommandLs(final Yum main) {
|
public CommandLs(final Yum main) {
|
||||||
super();
|
super("l");
|
||||||
setDescription("列出当前目录(服务器JAR为根目录)");
|
setDescription("列出当前目录(服务器JAR为根目录)");
|
||||||
setPossibleArguments("<相对目录>");
|
setPossibleArguments("<相对目录>");
|
||||||
}
|
}
|
||||||
|
@ -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 蒋天蓓 2015年8月12日下午2: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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,7 @@ public class FileCommand {
|
|||||||
cmdhandler.setAllCommandOnlyConsole(yum.config.getBoolean("onlyFileCommandConsole", true));
|
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 CommandRename(yum));
|
||||||
cmdhandler.registerCommand(new CommandRm(yum));
|
cmdhandler.registerCommand(new CommandRm(yum));
|
||||||
cmdhandler.registerCommand(new CommandLs(yum));
|
cmdhandler.registerCommand(new CommandLs(yum));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user