From b5479e480d7bc8b5dbffab5d0ee64a1e45c7e2b3 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Tue, 19 Oct 2021 13:35:00 +0100 Subject: [PATCH] Don't attempt to run null P2 tasks --- .../FaweDelegateRegionManager.java | 24 ++++++++++++++----- .../FaweDelegateSchematicHandler.java | 16 +++++++++---- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateRegionManager.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateRegionManager.java index 916a5ad3f..7d10ac33a 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateRegionManager.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateRegionManager.java @@ -73,7 +73,9 @@ public class FaweDelegateRegionManager { } catch (MaxChangedBlocksException e) { e.printStackTrace(); } finally { - TaskManager.IMP.task(whenDone); + if (whenDone != null) { + TaskManager.IMP.task(whenDone); + } } } }); @@ -176,7 +178,9 @@ public class FaweDelegateRegionManager { null, RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.IMP.LIGHTING.MODE) ); - TaskManager.IMP.task(whenDone); + if (whenDone != null) { + TaskManager.IMP.task(whenDone); + } } }); return true; @@ -239,7 +243,9 @@ public class FaweDelegateRegionManager { ), null, RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.IMP.LIGHTING.MODE) ); - TaskManager.IMP.task(whenDone); + if (whenDone != null) { + TaskManager.IMP.task(whenDone); + } } }); } @@ -266,7 +272,9 @@ public class FaweDelegateRegionManager { } catch (MaxChangedBlocksException e) { e.printStackTrace(); } - TaskManager.IMP.task(whenDone); + if (whenDone != null) { + TaskManager.IMP.task(whenDone); + } } }); } @@ -317,7 +325,9 @@ public class FaweDelegateRegionManager { e.printStackTrace(); } } - TaskManager.IMP.task(whenDone); + if (whenDone != null) { + TaskManager.IMP.task(whenDone); + } }); return true; } @@ -339,7 +349,9 @@ public class FaweDelegateRegionManager { editSession.regenerate(region); editSession.flushQueue(); } - TaskManager.IMP.task(whenDone); + if (whenDone != null) { + TaskManager.IMP.task(whenDone); + } } }); return true; diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateSchematicHandler.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateSchematicHandler.java index a2d60f2eb..e61cacce2 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateSchematicHandler.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateSchematicHandler.java @@ -70,7 +70,9 @@ public class FaweDelegateSchematicHandler { whenDone.value = false; } if (schematic == null) { - TaskManager.runTask(whenDone); + if (whenDone != null) { + TaskManager.runTask(whenDone); + } return; } BlockVector3 dimension = schematic.getClipboard().getDimensions(); @@ -82,7 +84,9 @@ public class FaweDelegateSchematicHandler { if (((region.getMaximumPoint().getX() - region.getMinimumPoint().getX() + xOffset + 1) < WIDTH) || ( (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ() + zOffset + 1) < LENGTH) || (HEIGHT > 256)) { - TaskManager.runTask(whenDone); + if (whenDone != null) { + TaskManager.runTask(whenDone); + } return; } // Calculate the optimal height to paste the schematic at @@ -121,7 +125,9 @@ public class FaweDelegateSchematicHandler { clipboard.paste(editSession, to, true, false, true); if (whenDone != null) { whenDone.value = true; - TaskManager.runTask(whenDone); + if (whenDone != null) { + TaskManager.runTask(whenDone); + } } } }; @@ -175,7 +181,9 @@ public class FaweDelegateSchematicHandler { public void upload(final CompoundTag tag, final UUID uuid, final String file, final RunnableVal whenDone) { if (tag == null) { LOGGER.warn("Cannot save empty tag"); - com.plotsquared.core.util.task.TaskManager.runTask(whenDone); + if (whenDone != null) { + TaskManager.runTask(whenDone); + } return; } final CompoundTag weTag = (CompoundTag) FaweCache.IMP.asTag(tag);