mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-19 10:25:00 +00:00
Added the ability to configure the schematic and CraftScript directories.
This commit is contained in:
parent
cd298c3099
commit
d1ff0250aa
@ -57,6 +57,8 @@ public abstract class LocalConfiguration {
|
|||||||
public int navigationWand = 345;
|
public int navigationWand = 345;
|
||||||
public int navigationWandMaxDistance = 50;
|
public int navigationWandMaxDistance = 50;
|
||||||
public int scriptTimeout = 3000;
|
public int scriptTimeout = 3000;
|
||||||
|
public String saveDir = "schematics";
|
||||||
|
public String scriptsDir = "craftscripts";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the configuration.
|
* Loads the configuration.
|
||||||
|
@ -343,6 +343,22 @@ public class WorldEdit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a file relative to the defined working directory. If the specified
|
||||||
|
* path is absolute, then the working directory is not used.
|
||||||
|
*
|
||||||
|
* @param path
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public File getWorkingDirectoryFile(String path) {
|
||||||
|
File f = new File(path);
|
||||||
|
if (f.isAbsolute()) {
|
||||||
|
return f;
|
||||||
|
} else {
|
||||||
|
return new File(config.getWorkingDirectory(), path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modulus, divisor-style.
|
* Modulus, divisor-style.
|
||||||
*
|
*
|
||||||
@ -757,7 +773,7 @@ public class WorldEdit {
|
|||||||
*/
|
*/
|
||||||
public void runScript(LocalPlayer player, String filename, String[] args)
|
public void runScript(LocalPlayer player, String filename, String[] args)
|
||||||
throws WorldEditException {
|
throws WorldEditException {
|
||||||
File dir = new File(config.getWorkingDirectory(), "craftscripts");
|
File dir = getWorkingDirectoryFile(config.scriptsDir);
|
||||||
File f = new File(dir, filename);
|
File f = new File(dir, filename);
|
||||||
|
|
||||||
if (!filename.matches("^[A-Za-z0-9_\\- \\./\\\\'\\$@~!%\\^\\*\\(\\)\\[\\]\\+\\{\\},\\?]+\\.[A-Za-z0-9]+$")) {
|
if (!filename.matches("^[A-Za-z0-9_\\- \\./\\\\'\\$@~!%\\^\\*\\(\\)\\[\\]\\+\\{\\},\\?]+\\.[A-Za-z0-9]+$")) {
|
||||||
|
@ -66,6 +66,9 @@ public class BukkitConfiguration extends LocalConfiguration {
|
|||||||
navigationWandMaxDistance = config.getInt("navigation-wand.max-distance", navigationWandMaxDistance);
|
navigationWandMaxDistance = config.getInt("navigation-wand.max-distance", navigationWandMaxDistance);
|
||||||
|
|
||||||
scriptTimeout = config.getInt("scripting.timeout", scriptTimeout);
|
scriptTimeout = config.getInt("scripting.timeout", scriptTimeout);
|
||||||
|
scriptsDir = config.getString("scripting.dir", scriptsDir);
|
||||||
|
|
||||||
|
saveDir = config.getString("saving.dir", saveDir);
|
||||||
|
|
||||||
disallowedBlocks = new HashSet<Integer>(config.getIntList("limits.disallowed-blocks", null));
|
disallowedBlocks = new HashSet<Integer>(config.getIntList("limits.disallowed-blocks", null));
|
||||||
|
|
||||||
|
@ -181,8 +181,8 @@ public class ClipboardCommands {
|
|||||||
LocalConfiguration config = we.getConfiguration();
|
LocalConfiguration config = we.getConfiguration();
|
||||||
|
|
||||||
String filename = args.getString(0).replace("\0", "") + ".schematic";
|
String filename = args.getString(0).replace("\0", "") + ".schematic";
|
||||||
File dir = new File(config.getWorkingDirectory(), "schematics");
|
File dir = we.getWorkingDirectoryFile(config.saveDir);
|
||||||
File f = new File(new File(config.getWorkingDirectory(), "schematics"), filename);
|
File f = new File(dir, filename);
|
||||||
|
|
||||||
if (!filename.matches("^[A-Za-z0-9_\\- \\./\\\\'\\$@~!%\\^\\*\\(\\)\\[\\]\\+\\{\\},\\?]+$")) {
|
if (!filename.matches("^[A-Za-z0-9_\\- \\./\\\\'\\$@~!%\\^\\*\\(\\)\\[\\]\\+\\{\\},\\?]+$")) {
|
||||||
player.printError("Valid characters: A-Z, a-z, 0-9, spaces, "
|
player.printError("Valid characters: A-Z, a-z, 0-9, spaces, "
|
||||||
@ -230,8 +230,8 @@ public class ClipboardCommands {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
File dir = new File(config.getWorkingDirectory(), "schematics");
|
File dir = we.getWorkingDirectoryFile(config.saveDir);
|
||||||
File f = new File(new File(config.getWorkingDirectory(), "schematics"), filename);
|
File f = new File(dir, filename);
|
||||||
|
|
||||||
if (!dir.exists()) {
|
if (!dir.exists()) {
|
||||||
if (!dir.mkdir()) {
|
if (!dir.mkdir()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user