This commit is contained in:
Jesse Boyd
2019-08-07 01:29:09 +10:00
parent 74fe88ae01
commit a3c58a187e
49 changed files with 604 additions and 808 deletions

View File

@@ -109,7 +109,7 @@ public final class WorldEdit {
private final PlatformManager platformManager = new PlatformManager(this);
private final EditSessionFactory editSessionFactory = new EditSessionFactory.EditSessionFactoryImpl(eventBus);
private final SessionManager sessions = new SessionManager(this);
private final ListeningExecutorService executorService = MoreExecutors.listeningDecorator(EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 20));
private final ListeningExecutorService executorService = MoreExecutors.listeningDecorator(EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 20));;
private final Supervisor supervisor = new SimpleSupervisor();
private final BlockFactory blockFactory = new BlockFactory(this);
@@ -232,7 +232,7 @@ public final class WorldEdit {
* traversal exploits by checking the root directory and the file directory.
* On success, a {@code java.io.File} object will be returned.
*
* @param player the player
* @param actor the actor
* @param dir sub-directory to look in
* @param filename filename (user-submitted)
* @param defaultExt append an extension if missing one, null to not use
@@ -240,8 +240,8 @@ public final class WorldEdit {
* @return a file
* @throws FilenameException thrown if the filename is invalid
*/
public File getSafeSaveFile(Player player, File dir, String filename, String defaultExt, String... extensions) throws FilenameException {
return getSafeFile(player, dir, filename, defaultExt, extensions, true);
public File getSafeSaveFile(Actor actor, File dir, String filename, String defaultExt, String... extensions) throws FilenameException {
return getSafeFile(actor, dir, filename, defaultExt, extensions, true);
}
/**
@@ -250,7 +250,7 @@ public final class WorldEdit {
* traversal exploits by checking the root directory and the file directory.
* On success, a {@code java.io.File} object will be returned.
*
* @param player the player
* @param actor the actor
* @param dir sub-directory to look in
* @param filename filename (user-submitted)
* @param defaultExt append an extension if missing one, null to not use
@@ -258,14 +258,14 @@ public final class WorldEdit {
* @return a file
* @throws FilenameException thrown if the filename is invalid
*/
public File getSafeOpenFile(Player player, File dir, String filename, String defaultExt, String... extensions) throws FilenameException {
return getSafeFile(player, dir, filename, defaultExt, extensions, false);
public File getSafeOpenFile(Actor actor, File dir, String filename, String defaultExt, String... extensions) throws FilenameException {
return getSafeFile(actor, dir, filename, defaultExt, extensions, false);
}
/**
* Get a safe path to a file.
*
* @param player the player
* @param actor the actor
* @param dir sub-directory to look in
* @param filename filename (user-submitted)
* @param defaultExt append an extension if missing one, null to not use
@@ -274,16 +274,16 @@ public final class WorldEdit {
* @return a file
* @throws FilenameException thrown if the filename is invalid
*/
private File getSafeFile(@Nullable Player player, File dir, String filename, String defaultExt, String[] extensions, boolean isSave) throws FilenameException {
private File getSafeFile(@Nullable Actor actor, File dir, String filename, String defaultExt, String[] extensions, boolean isSave) throws FilenameException {
if (extensions != null && (extensions.length == 1 && extensions[0] == null)) extensions = null;
File f;
if (filename.equals("#") && player != null) {
if (filename.equals("#") && actor != null) {
if (isSave) {
f = player.openFileSaveDialog(extensions);
f = actor.openFileSaveDialog(extensions);
} else {
f = player.openFileOpenDialog(extensions);
f = actor.openFileOpenDialog(extensions);
}
if (f == null) {