From 7a3d5bd7372b7be36160155ccac42d21146d2e61 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Wed, 25 Aug 2021 15:24:07 +0100 Subject: [PATCH] Don't trigger async catcher when adding chunk ticket - Apparently PaperLib#getChunkAtAsync#whenComplete doesn't necessarily run the task on the main thread --- .../plotsquared/bukkit/queue/BukkitChunkCoordinator.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitChunkCoordinator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitChunkCoordinator.java index 2b26f1750..e49bac132 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitChunkCoordinator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitChunkCoordinator.java @@ -28,6 +28,7 @@ package com.plotsquared.bukkit.queue; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import com.plotsquared.bukkit.BukkitPlatform; +import com.plotsquared.core.PlotSquared; import com.plotsquared.core.queue.ChunkCoordinator; import com.plotsquared.core.queue.subscriber.ProgressSubscriber; import com.plotsquared.core.util.task.PlotSquaredTask; @@ -36,7 +37,6 @@ import com.plotsquared.core.util.task.TaskTime; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.world.World; import io.papermc.lib.PaperLib; - import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.plugin.Plugin; @@ -204,8 +204,10 @@ public final class BukkitChunkCoordinator extends ChunkCoordinator { throwable.printStackTrace(); // We want one less because this couldn't be processed this.expectedSize.decrementAndGet(); - } else { + } else if (PlotSquared.get().isMainThread(Thread.currentThread())) { this.processChunk(chunkObject); + } else { + TaskManager.runTask(() -> this.processChunk(chunkObject)); } }); }