Don't trigger async catcher when adding chunk ticket

- Apparently PaperLib#getChunkAtAsync#whenComplete doesn't necessarily run the task on the main thread
This commit is contained in:
dordsor21 2021-08-25 15:24:07 +01:00
parent 2ab1973668
commit 7a3d5bd737
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B

View File

@ -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));
}
});
}