Skip to content

Commit

Permalink
Fixed bug when schematic file exists
Browse files Browse the repository at this point in the history
  • Loading branch information
LordTuxn committed Oct 6, 2021
1 parent 566e238 commit a2c29c2
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,13 @@ public static CompletableFuture<Void> Create(Player player, CityProject cityProj
filePath = Paths.get(schematicsPath, String.valueOf(cityProject.getServerID()), String.valueOf(cityProject.getID()), plotID + ".schematic").toString();
File schematic = new File(filePath);

if (!schematic.exists()) {
boolean createdDirs = schematic.getParentFile().mkdirs();
boolean createdFile = schematic.createNewFile();
if ((!schematic.getParentFile().exists() && !createdDirs) || (!schematic.exists() && !createdFile)) {
Bukkit.getLogger().log(Level.SEVERE, "Could not create schematic file! (" + filePath + ")");
player.sendMessage(Utils.getErrorMessageFormat("An error occurred while creating plot!"));
return CompletableFuture.completedFuture(null);
}
Files.deleteIfExists(schematic.getAbsoluteFile().toPath());
boolean createdDirs = schematic.getParentFile().mkdirs();
boolean createdFile = schematic.createNewFile();
if ((!schematic.getParentFile().exists() && !createdDirs) || (!schematic.exists() && !createdFile)) {
Bukkit.getLogger().log(Level.SEVERE, "Could not create schematic file! (" + filePath + ")");
player.sendMessage(Utils.getErrorMessageFormat("An error occurred while creating plot!"));
return CompletableFuture.completedFuture(null);
}

WorldEditPlugin worldEdit = PlotSystemTerra.DependencyManager.getWorldEditPlugin();
Expand Down

0 comments on commit a2c29c2

Please sign in to comment.