diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java index 0874c1ad4..968b4f68d 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -597,8 +597,8 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen } return; } - event.setCancelled(true); } + event.setCancelled(true); } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/PS.java b/Core/src/main/java/com/intellectualcrafters/plot/PS.java index 0c51aaacb..8b2b47fc3 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/PS.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/PS.java @@ -1726,7 +1726,7 @@ public class PS { if (!output.exists()) { output.mkdirs(); } - final File newFile = new File((output + File.separator + folder + File.separator + file)); + final File newFile = MainUtil.getFile(output, folder + File.separator + file); if (newFile.exists()) { return; } @@ -2063,6 +2063,9 @@ public class PS { options.put("approval.done.required-for-download", Settings.DOWNLOAD_REQUIRES_DONE); // Schematics + if (StringMan.isEqual(config.getString("schematic.save_path"), "plugins/PlotSquared/schematics")) { + config.set("schematics.save_path", Settings.SCHEMATIC_SAVE_PATH); + } options.put("schematics.save_path", Settings.SCHEMATIC_SAVE_PATH); options.put("bo3.save_path", Settings.BO3_SAVE_PATH); @@ -2177,6 +2180,8 @@ public class PS { // Schematics Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path"); + + Settings.BO3_SAVE_PATH = config.getString("bo3.save_path"); // Web diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Database.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Database.java index 396a8e8da..d56462616 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Database.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Database.java @@ -85,7 +85,7 @@ public class Database extends SubCommand { MainUtil.sendMessage(player, "/plot database import [sqlite file] [prefix]"); return false; } - File file = new File(PS.get().IMP.getDirectory() + File.separator + args[1] + ".db"); + File file = MainUtil.getFile(PS.get().IMP.getDirectory(), (args[1].endsWith(".db")) ? args[1] : args[1] + ".db"); if (!file.exists()) { MainUtil.sendMessage(player, "&6Database does not exist: " + file); return false; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java index f0f6f16d7..adbc9a47d 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -269,7 +269,7 @@ public class DebugExec extends SubCommand { case "addcmd": try { final String cmd = StringMan.join(Files - .readLines(new File(new File(PS.get().IMP.getDirectory() + File.separator + "scripts"), args[1]), + .readLines(MainUtil.getFile(new File(PS.get().IMP.getDirectory() + File.separator + "scripts"), args[1]), StandardCharsets.UTF_8), System.getProperty("line.separator")); final Command subcommand = new Command(args[1].split("\\.")[0]) { @@ -298,7 +298,7 @@ public class DebugExec extends SubCommand { async = true; case "run": try { - script = StringMan.join(Files.readLines(new File(new File(PS.get().IMP.getDirectory() + File.separator + "scripts"), args[1]), StandardCharsets.UTF_8), + script = StringMan.join(Files.readLines(MainUtil.getFile(new File(PS.get().IMP.getDirectory() + File.separator + "scripts"), args[1]), StandardCharsets.UTF_8), System.getProperty("line.separator")); if (args.length > 2) { final HashMap replacements = new HashMap<>(); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/plugin.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/plugin.java index b750a7e6f..17cbee36c 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/plugin.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/plugin.java @@ -21,25 +21,16 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PS; -import com.intellectualcrafters.plot.object.ChunkLoc; -import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.SetQueue; import com.intellectualcrafters.plot.util.StringMan; import com.plotsquared.general.commands.CommandDeclaration; -import java.util.Collections; - @CommandDeclaration(command = "plugin", permission = "plots.use", description = "Show plugin information", aliases = { "version" }, category = CommandCategory.INFO) public class plugin extends SubCommand { @Override public boolean onCommand(final PlotPlayer plr, final String[] args) { - Location loc = plr.getLocation(); - ChunkLoc cl = loc.getChunkLoc(); - SetQueue.IMP.queue.sendChunk(loc.getWorld(), Collections.singletonList(cl)); - MainUtil.sendMessage(plr, String.format("$2>> $1&lPlotSquared $2($1Version$2: $1%s$2)", StringMan.join(PS.get().IMP.getPluginVersion(), "."))); MainUtil.sendMessage(plr, "$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92"); MainUtil.sendMessage(plr, "$2>> $1&lWiki$2: $1https://github.com/IntellectualCrafters/PlotSquared/wiki"); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/config/Settings.java b/Core/src/main/java/com/intellectualcrafters/plot/config/Settings.java index 548ebb750..3dc6a7c03 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -113,7 +113,7 @@ public class Settings { /** * Schematic Save Path */ - public static String SCHEMATIC_SAVE_PATH = "plugins/PlotSquared/schematics"; + public static String SCHEMATIC_SAVE_PATH = "schematics"; /** * BO3 Save Path */ diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/BO3Handler.java b/Core/src/main/java/com/intellectualcrafters/plot/util/BO3Handler.java index 40487e35a..e63faae92 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/BO3Handler.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/BO3Handler.java @@ -185,9 +185,9 @@ public class BO3Handler { } File bo3File; if ((bo3.getLoc().x == 0) && (bo3.getLoc().z == 0)) { - bo3File = new File(base.getParentFile(), bo3.getName() + ".bo3"); + bo3File = MainUtil.getFile(base.getParentFile(), bo3.getName() + ".bo3"); } else { - bo3File = new File(base.getParentFile(), bo3.getName() + "_" + bo3.getLoc().x + "_" + bo3.getLoc().z + ".bo3"); + bo3File = MainUtil.getFile(base.getParentFile(), bo3.getName() + "_" + bo3.getLoc().x + "_" + bo3.getLoc().z + ".bo3"); } bo3File.createNewFile(); Files.write(bo3File.toPath(), StringMan.join(lines, System.getProperty("line.separator")).getBytes(), StandardOpenOption.WRITE); @@ -199,7 +199,7 @@ public class BO3Handler { } public static File getBaseFile(final String category) { - final File base = new File(PS.get().IMP.getDirectory(), Settings.BO3_SAVE_PATH + File.separator + category + File.separator + "base.yml"); + final File base = MainUtil.getFile(PS.get().IMP.getDirectory(), Settings.BO3_SAVE_PATH + File.separator + category + File.separator + "base.yml"); if (!base.exists()) { PS.get().copyFile("base.yml", Settings.BO3_SAVE_PATH + File.separator + category); } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 49a892fd7..984e49f92 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -28,6 +28,8 @@ import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.*; +import java.io.File; +import java.nio.file.Paths; import java.util.*; import java.util.Map.Entry; import java.util.regex.Matcher; @@ -417,6 +419,13 @@ public class MainUtil { SetQueue.IMP.queue.sendChunk(world, Collections.singletonList(loc)); } + public static File getFile(File base, String path) { + if (Paths.get(path).isAbsolute()) { + return new File(path); + } + return new File(base, path); + } + /** * Set a cuboid in the world to a set of blocks. * @param world diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java b/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java index 1471e284b..99db22e59 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -450,13 +450,13 @@ public abstract class SchematicHandler { * @return schematic if found, else null */ public Schematic getSchematic(final String name) { - final File parent = new File(PS.get().IMP.getDirectory() + File.separator + "schematics"); + final File parent = MainUtil.getFile(PS.get().IMP.getDirectory(), Settings.SCHEMATIC_SAVE_PATH); if (!parent.exists()) { if (!parent.mkdir()) { throw new RuntimeException("Could not create schematic parent directory"); } } - final File file = new File(PS.get().IMP.getDirectory() + File.separator + "schematics" + File.separator + name + (name.endsWith(".schematic") ? "" : ".schematic")); + final File file = MainUtil.getFile(PS.get().IMP.getDirectory(), Settings.SCHEMATIC_SAVE_PATH + File.separator + name + (name.endsWith(".schematic") ? "" : ".schematic")); return getSchematic(file); } @@ -616,9 +616,9 @@ public abstract class SchematicHandler { return false; } try { - final File tmp = new File(path); + final File tmp = MainUtil.getFile(PS.get().IMP.getDirectory(), path); tmp.getParentFile().mkdirs(); - try (OutputStream stream = new FileOutputStream(path); NBTOutputStream output = new NBTOutputStream(new GZIPOutputStream(stream))) { + try (OutputStream stream = new FileOutputStream(tmp); NBTOutputStream output = new NBTOutputStream(new GZIPOutputStream(stream))) { output.writeTag(tag); } } catch (final IOException e) { diff --git a/target/PlotSquared-Bukkit.jar b/target/PlotSquared-Bukkit.jar index d15f64105..7c82a2f40 100644 Binary files a/target/PlotSquared-Bukkit.jar and b/target/PlotSquared-Bukkit.jar differ