mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2024-12-27 05:00:08 +08:00
Changed getSafe*File to accept varargs instead of arrays.
This commit is contained in:
parent
c8180e641f
commit
5d59dd764e
@ -646,7 +646,7 @@ public Set<Integer> getBlockIDs(LocalPlayer player,
|
||||
* @throws FilenameException
|
||||
*/
|
||||
public File getSafeSaveFile(LocalPlayer player, File dir, String filename,
|
||||
String defaultExt, String[] extensions)
|
||||
String defaultExt, String... extensions)
|
||||
throws FilenameException {
|
||||
return getSafeFile(player, dir, filename, defaultExt, extensions, true);
|
||||
}
|
||||
@ -666,7 +666,7 @@ public File getSafeSaveFile(LocalPlayer player, File dir, String filename,
|
||||
* @throws FilenameException
|
||||
*/
|
||||
public File getSafeOpenFile(LocalPlayer player, File dir, String filename,
|
||||
String defaultExt, String[] extensions)
|
||||
String defaultExt, String... extensions)
|
||||
throws FilenameException {
|
||||
return getSafeFile(player, dir, filename, defaultExt, extensions, false);
|
||||
}
|
||||
@ -686,6 +686,8 @@ public File getSafeOpenFile(LocalPlayer player, File dir, String filename,
|
||||
private File getSafeFile(LocalPlayer player, File dir, String filename,
|
||||
String defaultExt, String[] extensions, boolean isSave)
|
||||
throws FilenameException {
|
||||
if (extensions.length == 1 && extensions[0] == null) extensions = null;
|
||||
|
||||
File f;
|
||||
|
||||
if (filename.equals("#")) {
|
||||
|
@ -188,8 +188,7 @@ public static void load(CommandContext args, WorldEdit we,
|
||||
|
||||
String filename = args.getString(0);
|
||||
File dir = we.getWorkingDirectoryFile(config.saveDir);
|
||||
File f = we.getSafeOpenFile(player, dir, filename, "schematic",
|
||||
new String[] { "schematic" });
|
||||
File f = we.getSafeOpenFile(player, dir, filename, "schematic", "schematic");
|
||||
|
||||
try {
|
||||
String filePath = f.getCanonicalPath();
|
||||
@ -226,8 +225,7 @@ public static void save(CommandContext args, WorldEdit we,
|
||||
String filename = args.getString(0);
|
||||
|
||||
File dir = we.getWorkingDirectoryFile(config.saveDir);
|
||||
File f = we.getSafeSaveFile(player, dir, filename, "schematic",
|
||||
new String[] { "schematic" });
|
||||
File f = we.getSafeSaveFile(player, dir, filename, "schematic", "schematic");
|
||||
|
||||
if (!dir.exists()) {
|
||||
if (!dir.mkdir()) {
|
||||
|
@ -57,8 +57,7 @@ public static void execute(CommandContext args, WorldEdit we,
|
||||
session.setLastScript(name);
|
||||
|
||||
File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir);
|
||||
File f = we.getSafeOpenFile(player, dir, name, "js",
|
||||
new String[] { "js" });
|
||||
File f = we.getSafeOpenFile(player, dir, name, "js", "js");
|
||||
|
||||
we.runScript(player, f, scriptArgs);
|
||||
}
|
||||
@ -91,8 +90,7 @@ public static void executeLast(CommandContext args, WorldEdit we,
|
||||
String[] scriptArgs = args.getSlice(0);
|
||||
|
||||
File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir);
|
||||
File f = we.getSafeOpenFile(player, dir, lastScript, "js",
|
||||
new String[] { "js" });
|
||||
File f = we.getSafeOpenFile(player, dir, lastScript, "js", "js");
|
||||
|
||||
we.runScript(player, f, scriptArgs);
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ public Set<Integer> getBlockIDs(String list, boolean allBlocksAllowed)
|
||||
@Deprecated
|
||||
public File getSafeFile(String folder, String filename) throws FilenameException {
|
||||
File dir = controller.getWorkingDirectoryFile(folder);
|
||||
return controller.getSafeOpenFile(player, dir, filename, null, null);
|
||||
return controller.getSafeOpenFile(player, dir, filename, null, (String[]) null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -236,7 +236,7 @@ public File getSafeFile(String folder, String filename) throws FilenameException
|
||||
* @throws FilenameException
|
||||
*/
|
||||
public File getSafeOpenFile(String folder, String filename,
|
||||
String defaultExt, String[] exts)
|
||||
String defaultExt, String... exts)
|
||||
throws FilenameException {
|
||||
File dir = controller.getWorkingDirectoryFile(folder);
|
||||
return controller.getSafeOpenFile(player, dir, filename, defaultExt, exts);
|
||||
@ -259,7 +259,7 @@ public File getSafeOpenFile(String folder, String filename,
|
||||
* @throws FilenameException
|
||||
*/
|
||||
public File getSafeSaveFile(String folder, String filename,
|
||||
String defaultExt, String[] exts)
|
||||
String defaultExt, String... exts)
|
||||
throws FilenameException {
|
||||
File dir = controller.getWorkingDirectoryFile(folder);
|
||||
return controller.getSafeSaveFile(player, dir, filename, defaultExt, exts);
|
||||
|
Loading…
Reference in New Issue
Block a user