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

Added LocalConfiguration.getWorkingDirectory().

Dieser Commit ist enthalten in:
sk89q 2011-01-27 01:51:34 -08:00
Ursprung 68db2ebdd9
Commit 5d444d20a1
3 geänderte Dateien mit 19 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -260,7 +260,7 @@ public class CuboidClipboard {
* @throws IOException
* @throws DataException
*/
public void saveSchematic(String path) throws IOException, DataException {
public void saveSchematic(File path) throws IOException, DataException {
int width = getWidth();
int height = getHeight();
int length = getLength();
@ -342,7 +342,7 @@ public class CuboidClipboard {
* @throws DataException
* @throws IOException
*/
public static CuboidClipboard loadSchematic(String path)
public static CuboidClipboard loadSchematic(File path)
throws DataException, IOException {
FileInputStream stream = new FileInputStream(path);
NBTInputStream nbtStream = new NBTInputStream(stream);

Datei anzeigen

@ -19,6 +19,7 @@
package com.sk89q.worldedit;
import java.io.File;
import java.util.HashSet;
import java.util.Set;
@ -61,4 +62,13 @@ public abstract class LocalConfiguration {
* Loads the configuration.
*/
public abstract void load();
/**
* Get the working directory to work from.
*
* @return
*/
public File getWorkingDirectory() {
return new File(".");
}
}

Datei anzeigen

@ -981,8 +981,8 @@ public class WorldEdit {
} else if (split[0].equalsIgnoreCase("//load")) {
checkArgs(split, 1, 1, split[0]);
String filename = split[1].replace("\0", "") + ".schematic";
File dir = new File("schematics");
File f = new File("schematics", filename);
File dir = new File(config.getWorkingDirectory(), "schematics");
File f = new File(new File(config.getWorkingDirectory(), "schematics"), filename);
if (!filename.matches("^[A-Za-z0-9_\\- \\./\\\\'\\$@~!%\\^\\*\\(\\)\\[\\]\\+\\{\\},\\?]+$")) {
player.printError("Valid characters: A-Z, a-z, 0-9, spaces, "
@ -997,7 +997,7 @@ public class WorldEdit {
if (!filePath.substring(0, dirPath.length()).equals(dirPath)) {
player.printError("Schematic could not read or it does not exist.");
} else {
session.setClipboard(CuboidClipboard.loadSchematic(filePath));
session.setClipboard(CuboidClipboard.loadSchematic(f));
logger.log(Level.INFO, player.getName() + " loaded " + filePath);
player.print(filename + " loaded. Paste it with //paste");
}
@ -1020,8 +1020,8 @@ public class WorldEdit {
return true;
}
File dir = new File("schematics");
File f = new File("schematics", filename);
File dir = new File(config.getWorkingDirectory(), "schematics");
File f = new File(new File(config.getWorkingDirectory(), "schematics"), filename);
if (!dir.exists()) {
if (!dir.mkdir()) {
@ -1043,7 +1043,7 @@ public class WorldEdit {
parent.mkdirs();
}
session.getClipboard().saveSchematic(filePath);
session.getClipboard().saveSchematic(f);
logger.log(Level.INFO, player.getName() + " saved " + filePath);
player.print(filename + " saved.");
}
@ -2211,7 +2211,7 @@ public class WorldEdit {
*/
public void runScript(LocalPlayer player, String filename, String[] args)
throws WorldEditException {
File dir = new File("craftscripts");
File dir = new File(config.getWorkingDirectory(), "craftscripts");
File f = new File(dir, filename);
if (!filename.matches("^[A-Za-z0-9_\\- \\./\\\\'\\$@~!%\\^\\*\\(\\)\\[\\]\\+\\{\\},\\?]+\\.[A-Za-z0-9]+$")) {