mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 15:49:00 +01:00
Fix plugins calling getChunkAtAsync asynchronously
While this method has async in it's name, it's not actually meant to be called asynchronously.... It just means IT will load the chunk asynchronously without blocking main. So fix this so that if a plugin calls it async, it forces the request back to main thread.
This commit is contained in:
parent
238ab72fce
commit
18bd266258
2 changed files with 13 additions and 1 deletions
|
@ -4182,6 +4182,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ if (immediate != null) {
|
||||
+ return CompletableFuture.completedFuture(immediate.getBukkitChunk());
|
||||
+ }
|
||||
+ } else {
|
||||
+ CompletableFuture<Chunk> future = new CompletableFuture<Chunk>();
|
||||
+ world.getMinecraftServer().execute(() -> {
|
||||
+ getChunkAtAsync(x, z, gen, urgent).whenComplete((chunk, err) -> {
|
||||
+ if (err != null) {
|
||||
+ future.completeExceptionally(err);
|
||||
+ } else {
|
||||
+ future.complete(chunk);
|
||||
+ }
|
||||
+ });
|
||||
+ });
|
||||
+ return future;
|
||||
+ }
|
||||
+
|
||||
+ return this.world.getChunkProvider().getChunkAtAsynchronously(x, z, gen, urgent).thenComposeAsync((either) -> {
|
||||
|
|
|
@ -823,7 +823,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -0,0 +0,0 @@ public class CraftWorld implements World {
|
||||
}
|
||||
return future;
|
||||
}
|
||||
|
||||
+ if (!urgent) {
|
||||
|
|
Loading…
Reference in a new issue