From f0cbc4f23e680cb5a9e566ea45f4c70f50c6b523 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Tue, 8 Jun 2021 19:32:13 +0100 Subject: [PATCH] Add whenDone task to setCuboids and ensure whenDone tasks are added to the queue before FAWE might do something --- .../bukkit/util/fawe/FaweRegionManager.java | 6 +++--- .../com/plotsquared/core/command/DebugRoadRegen.java | 7 +++---- .../main/java/com/plotsquared/core/command/Set.java | 6 +++--- .../core/components/ComponentPresetManager.java | 2 +- .../core/generator/HybridPlotManager.java | 12 ++++++------ gradle/libs.versions.toml | 2 +- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/fawe/FaweRegionManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/fawe/FaweRegionManager.java index 6bee51371..825ac9f9b 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/fawe/FaweRegionManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/fawe/FaweRegionManager.java @@ -67,10 +67,10 @@ public class FaweRegionManager extends BukkitRegionManager { final @NonNull Pattern blocks, int minY, int maxY, - @org.checkerframework.checker.nullness.qual.Nullable PlotPlayer actor, - @org.checkerframework.checker.nullness.qual.Nullable QueueCoordinator queue + @Nullable PlotPlayer actor, + @Nullable QueueCoordinator queue ) { - return delegate.setCuboids(area, regions, blocks, minY, maxY); + return delegate.setCuboids(area, regions, blocks, minY, maxY, queue.getCompleteTask()); } @Override diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugRoadRegen.java b/Core/src/main/java/com/plotsquared/core/command/DebugRoadRegen.java index 7b9fbdb09..1745588f1 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugRoadRegen.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugRoadRegen.java @@ -107,11 +107,7 @@ public class DebugRoadRegen extends SubCommand { } else { PlotManager manager = area.getPlotManager(); QueueCoordinator queue = area.getQueue(); - manager.createRoadEast(plot, queue); - manager.createRoadSouth(plot, queue); - manager.createRoadSouthEast(plot, queue); queue.setCompleteTask(() -> { - ; player.sendMessage( TranslatableCaption.of("debugroadregen.regen_done"), Template.of("value", plot.getId().toString()) @@ -121,6 +117,9 @@ public class DebugRoadRegen extends SubCommand { Template.of("value", "/plot regenallroads") ); }); + manager.createRoadEast(plot, queue); + manager.createRoadSouth(plot, queue); + manager.createRoadSouthEast(plot, queue); queue.enqueue(); } return true; diff --git a/Core/src/main/java/com/plotsquared/core/command/Set.java b/Core/src/main/java/com/plotsquared/core/command/Set.java index 748aa01c2..f745f176b 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Set.java +++ b/Core/src/main/java/com/plotsquared/core/command/Set.java @@ -161,9 +161,6 @@ public class Set extends SubCommand { BackupManager.backup(player, plot, () -> { plot.addRunning(); QueueCoordinator queue = plotArea.getQueue(); - for (final Plot current : plot.getConnectedPlots()) { - current.getPlotModificationManager().setComponent(component, pattern, player, queue); - } queue.setCompleteTask(() -> { plot.removeRunning(); player.sendMessage( @@ -179,6 +176,9 @@ public class Set extends SubCommand { .getInstance(ProgressSubscriberFactory.class) .createWithActor(player)); } + for (final Plot current : plot.getConnectedPlots()) { + current.getPlotModificationManager().setComponent(component, pattern, player, queue); + } queue.enqueue(); player.sendMessage(TranslatableCaption.of("working.generating_component")); }); diff --git a/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java b/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java index 5f61ce164..fa4ab0030 100644 --- a/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java +++ b/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java @@ -222,6 +222,7 @@ public class ComponentPresetManager { BackupManager.backup(getPlayer(), plot, () -> { plot.addRunning(); QueueCoordinator queue = plot.getArea().getQueue(); + queue.setCompleteTask(plot::removeRunning); for (Plot current : plot.getConnectedPlots()) { current.getPlotModificationManager().setComponent( componentPreset.getComponent().name(), @@ -230,7 +231,6 @@ public class ComponentPresetManager { queue ); } - queue.setCompleteTask(plot::removeRunning); queue.enqueue(); getPlayer().sendMessage(TranslatableCaption.of("working.generating_component")); }); diff --git a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotManager.java b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotManager.java index 8487adb45..cc5d34669 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotManager.java +++ b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotManager.java @@ -263,6 +263,12 @@ public class HybridPlotManager extends ClassicPlotManager { enqueue = true; queue = hybridPlotWorld.getQueue(); } + if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) { + queue.addProgressSubscriber(subscriberFactory.createWithActor(actor)); + } + if (whenDone != null) { + queue.setCompleteTask(whenDone); + } if (!canRegen) { queue.setCuboid(pos1.withY(0), pos2.withY(0), bedrock); // Each component has a different layer @@ -274,12 +280,6 @@ public class HybridPlotManager extends ClassicPlotManager { queue.setRegenRegion(new CuboidRegion(pos1.getBlockVector3(), pos2.getBlockVector3())); } pastePlotSchematic(queue, pos1, pos2); - if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) { - queue.addProgressSubscriber(subscriberFactory.createWithActor(actor)); - } - if (whenDone != null) { - queue.setCompleteTask(whenDone); - } return !enqueue || queue.enqueue(); } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 97a447520..4e1160fc5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,7 +14,7 @@ guice = "5.0.1" findbugs = "3.0.1" worldedit = "7.2.5" -fawe = "p2v6-8" +fawe = "p2v6-9" vault = "1.7" placeholderapi = "2.10.9" luckperms = "5.3"