mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-12-26 17:18:43 +01:00
Fix #938
This commit is contained in:
parent
62531a42c7
commit
b59665b00b
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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<PlotPlayer> subcommand = new Command<PlotPlayer>(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<String, String> replacements = new HashMap<>();
|
||||
|
@ -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");
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user