From 5fa8189596ac8ce01f11ff8024fae11dfabd9aa4 Mon Sep 17 00:00:00 2001 From: A248 <anandebeh@gmail.com> Date: Sun, 15 Nov 2020 19:26:25 -0500 Subject: [PATCH] Add exception handlers for getChunkAtAsync convenience methods --- Spigot-API-Patches/Async-Chunks-API.patch | 25 ++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Spigot-API-Patches/Async-Chunks-API.patch b/Spigot-API-Patches/Async-Chunks-API.patch index 776df034cd..e26575cbe4 100644 --- a/Spigot-API-Patches/Async-Chunks-API.patch +++ b/Spigot-API-Patches/Async-Chunks-API.patch @@ -63,7 +63,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @Deprecated + public default void getChunkAtAsync(int x, int z, @NotNull ChunkLoadCallback cb) { -+ getChunkAtAsync(x, z, true).thenAccept(cb::onLoad); ++ getChunkAtAsync(x, z, true).thenAccept(cb::onLoad).exceptionally((ex) -> { ++ Bukkit.getLogger().log(java.util.logging.Level.WARNING, "Exception in chunk load callback", ex); ++ return null; ++ }); + } + + /** @@ -86,7 +89,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @Deprecated + public default void getChunkAtAsync(@NotNull Location loc, @NotNull ChunkLoadCallback cb) { -+ getChunkAtAsync(loc, true).thenAccept(cb::onLoad); ++ getChunkAtAsync(loc, true).thenAccept(cb::onLoad).exceptionally((ex) -> { ++ Bukkit.getLogger().log(java.util.logging.Level.WARNING, "Exception in chunk load callback", ex); ++ return null; ++ }); + } + + /** @@ -109,7 +115,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @Deprecated + public default void getChunkAtAsync(@NotNull Block block, @NotNull ChunkLoadCallback cb) { -+ getChunkAtAsync(block, true).thenAccept(cb::onLoad); ++ getChunkAtAsync(block, true).thenAccept(cb::onLoad).exceptionally((ex) -> { ++ Bukkit.getLogger().log(java.util.logging.Level.WARNING, "Exception in chunk load callback", ex); ++ return null; ++ }); + } + + /** @@ -131,7 +140,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * will be executed synchronously + */ + public default void getChunkAtAsync(int x, int z, @NotNull java.util.function.Consumer<Chunk> cb) { -+ getChunkAtAsync(x, z, true).thenAccept(cb); ++ getChunkAtAsync(x, z, true).thenAccept(cb).exceptionally((ex) -> { ++ Bukkit.getLogger().log(java.util.logging.Level.WARNING, "Exception in chunk load callback", ex); ++ return null; ++ }); + } + + /** @@ -154,7 +166,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * will be executed synchronously + */ + public default void getChunkAtAsync(int x, int z, boolean gen, @NotNull java.util.function.Consumer<Chunk> cb) { -+ getChunkAtAsync(x, z, gen).thenAccept(cb); ++ getChunkAtAsync(x, z, gen).thenAccept(cb).exceptionally((ex) -> { ++ Bukkit.getLogger().log(java.util.logging.Level.WARNING, "Exception in chunk load callback", ex); ++ return null; ++ }); + } + + /**