mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-19 10:25:00 +00:00
Changed getSafe*File to accept varargs instead of arrays.
This commit is contained in:
parent
c8180e641f
commit
5d59dd764e
@ -646,7 +646,7 @@ public class WorldEdit {
|
|||||||
* @throws FilenameException
|
* @throws FilenameException
|
||||||
*/
|
*/
|
||||||
public File getSafeSaveFile(LocalPlayer player, File dir, String filename,
|
public File getSafeSaveFile(LocalPlayer player, File dir, String filename,
|
||||||
String defaultExt, String[] extensions)
|
String defaultExt, String... extensions)
|
||||||
throws FilenameException {
|
throws FilenameException {
|
||||||
return getSafeFile(player, dir, filename, defaultExt, extensions, true);
|
return getSafeFile(player, dir, filename, defaultExt, extensions, true);
|
||||||
}
|
}
|
||||||
@ -666,7 +666,7 @@ public class WorldEdit {
|
|||||||
* @throws FilenameException
|
* @throws FilenameException
|
||||||
*/
|
*/
|
||||||
public File getSafeOpenFile(LocalPlayer player, File dir, String filename,
|
public File getSafeOpenFile(LocalPlayer player, File dir, String filename,
|
||||||
String defaultExt, String[] extensions)
|
String defaultExt, String... extensions)
|
||||||
throws FilenameException {
|
throws FilenameException {
|
||||||
return getSafeFile(player, dir, filename, defaultExt, extensions, false);
|
return getSafeFile(player, dir, filename, defaultExt, extensions, false);
|
||||||
}
|
}
|
||||||
@ -686,6 +686,8 @@ public class WorldEdit {
|
|||||||
private File getSafeFile(LocalPlayer player, File dir, String filename,
|
private File getSafeFile(LocalPlayer player, File dir, String filename,
|
||||||
String defaultExt, String[] extensions, boolean isSave)
|
String defaultExt, String[] extensions, boolean isSave)
|
||||||
throws FilenameException {
|
throws FilenameException {
|
||||||
|
if (extensions.length == 1 && extensions[0] == null) extensions = null;
|
||||||
|
|
||||||
File f;
|
File f;
|
||||||
|
|
||||||
if (filename.equals("#")) {
|
if (filename.equals("#")) {
|
||||||
|
@ -188,8 +188,7 @@ public class ClipboardCommands {
|
|||||||
|
|
||||||
String filename = args.getString(0);
|
String filename = args.getString(0);
|
||||||
File dir = we.getWorkingDirectoryFile(config.saveDir);
|
File dir = we.getWorkingDirectoryFile(config.saveDir);
|
||||||
File f = we.getSafeOpenFile(player, dir, filename, "schematic",
|
File f = we.getSafeOpenFile(player, dir, filename, "schematic", "schematic");
|
||||||
new String[] { "schematic" });
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String filePath = f.getCanonicalPath();
|
String filePath = f.getCanonicalPath();
|
||||||
@ -226,8 +225,7 @@ public class ClipboardCommands {
|
|||||||
String filename = args.getString(0);
|
String filename = args.getString(0);
|
||||||
|
|
||||||
File dir = we.getWorkingDirectoryFile(config.saveDir);
|
File dir = we.getWorkingDirectoryFile(config.saveDir);
|
||||||
File f = we.getSafeSaveFile(player, dir, filename, "schematic",
|
File f = we.getSafeSaveFile(player, dir, filename, "schematic", "schematic");
|
||||||
new String[] { "schematic" });
|
|
||||||
|
|
||||||
if (!dir.exists()) {
|
if (!dir.exists()) {
|
||||||
if (!dir.mkdir()) {
|
if (!dir.mkdir()) {
|
||||||
|
@ -57,8 +57,7 @@ public class ScriptingCommands {
|
|||||||
session.setLastScript(name);
|
session.setLastScript(name);
|
||||||
|
|
||||||
File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir);
|
File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir);
|
||||||
File f = we.getSafeOpenFile(player, dir, name, "js",
|
File f = we.getSafeOpenFile(player, dir, name, "js", "js");
|
||||||
new String[] { "js" });
|
|
||||||
|
|
||||||
we.runScript(player, f, scriptArgs);
|
we.runScript(player, f, scriptArgs);
|
||||||
}
|
}
|
||||||
@ -91,8 +90,7 @@ public class ScriptingCommands {
|
|||||||
String[] scriptArgs = args.getSlice(0);
|
String[] scriptArgs = args.getSlice(0);
|
||||||
|
|
||||||
File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir);
|
File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir);
|
||||||
File f = we.getSafeOpenFile(player, dir, lastScript, "js",
|
File f = we.getSafeOpenFile(player, dir, lastScript, "js", "js");
|
||||||
new String[] { "js" });
|
|
||||||
|
|
||||||
we.runScript(player, f, scriptArgs);
|
we.runScript(player, f, scriptArgs);
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ public class CraftScriptContext extends CraftScriptEnvironment {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public File getSafeFile(String folder, String filename) throws FilenameException {
|
public File getSafeFile(String folder, String filename) throws FilenameException {
|
||||||
File dir = controller.getWorkingDirectoryFile(folder);
|
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
|
* @throws FilenameException
|
||||||
*/
|
*/
|
||||||
public File getSafeOpenFile(String folder, String filename,
|
public File getSafeOpenFile(String folder, String filename,
|
||||||
String defaultExt, String[] exts)
|
String defaultExt, String... exts)
|
||||||
throws FilenameException {
|
throws FilenameException {
|
||||||
File dir = controller.getWorkingDirectoryFile(folder);
|
File dir = controller.getWorkingDirectoryFile(folder);
|
||||||
return controller.getSafeOpenFile(player, dir, filename, defaultExt, exts);
|
return controller.getSafeOpenFile(player, dir, filename, defaultExt, exts);
|
||||||
@ -259,7 +259,7 @@ public class CraftScriptContext extends CraftScriptEnvironment {
|
|||||||
* @throws FilenameException
|
* @throws FilenameException
|
||||||
*/
|
*/
|
||||||
public File getSafeSaveFile(String folder, String filename,
|
public File getSafeSaveFile(String folder, String filename,
|
||||||
String defaultExt, String[] exts)
|
String defaultExt, String... exts)
|
||||||
throws FilenameException {
|
throws FilenameException {
|
||||||
File dir = controller.getWorkingDirectoryFile(folder);
|
File dir = controller.getWorkingDirectoryFile(folder);
|
||||||
return controller.getSafeSaveFile(player, dir, filename, defaultExt, exts);
|
return controller.getSafeSaveFile(player, dir, filename, defaultExt, exts);
|
||||||
|
Loading…
Reference in New Issue
Block a user