Skip to content

Commit

Permalink
Delete world if an exception was thrown
Browse files Browse the repository at this point in the history
  • Loading branch information
LordTuxn committed Sep 23, 2021
1 parent 689afc8 commit ea6ea65
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ public AbstractPlotGenerator(@NotNull Plot plot, @NotNull Builder builder) {
} catch (InterruptedException | ExecutionException ex) { plotGen.completeExceptionally(ex); }
})).whenComplete((t, exception) -> {
try {
if (exception != null) onException(exception);
if (exception != null) {
onException(exception);
if (worldManager.isMVWorld(plot.getPlotWorld())) worldManager.deleteWorld(plot.getWorldName(), true, true);
}
this.onComplete(exception != null);
} catch (SQLException ex) { PlotHandler.abandonPlot(plot); onException(ex); }
});
Expand All @@ -103,9 +106,8 @@ protected CompletableFuture<Boolean> configureWorldGeneration() {
protected CompletableFuture<Boolean> generateWorld() {
// Check if world creator is configured and add new world to multiverse world manager
if (worldCreator != null) {
if (!worldManager.isMVWorld(plot.getPlotWorld())) {
worldManager.addWorld(plot.getWorldName(), worldCreator.environment(), null, worldCreator.type(), false, "VoidGen");
}
if (worldManager.isMVWorld(plot.getPlotWorld())) worldManager.deleteWorld(plot.getWorldName(), true, true);
worldManager.addWorld(plot.getWorldName(), worldCreator.environment(), null, worldCreator.type(), false, "VoidGen");
} else {
Bukkit.getLogger().log(Level.SEVERE, "World Creator is not configured!");
return CompletableFuture.completedFuture(false);
Expand Down

0 comments on commit ea6ea65

Please sign in to comment.