3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-24 18:10:08 +01:00

Changed getSafe*File to accept varargs instead of arrays.

Dieser Commit ist enthalten in:
TomyLobo 2011-11-27 05:29:49 +01:00
Ursprung c8180e641f
Commit 5d59dd764e
4 geänderte Dateien mit 11 neuen und 13 gelöschten Zeilen

Datei anzeigen

@ -646,7 +646,7 @@ public class WorldEdit {
* @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 class WorldEdit {
* @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 class WorldEdit {
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("#")) {

Datei anzeigen

@ -188,8 +188,7 @@ public class ClipboardCommands {
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 class ClipboardCommands {
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()) {

Datei anzeigen

@ -57,8 +57,7 @@ public class ScriptingCommands {
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 class ScriptingCommands {
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);
}

Datei anzeigen

@ -216,7 +216,7 @@ public class CraftScriptContext extends CraftScriptEnvironment {
@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 class CraftScriptContext extends CraftScriptEnvironment {
* @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 class CraftScriptContext extends CraftScriptEnvironment {
* @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);