From 475f6372e271e95194c2c039f8414acc1e8aa14b Mon Sep 17 00:00:00 2001 From: tastybento Date: Fri, 31 May 2024 17:11:43 -0700 Subject: [PATCH] Added defensive code for JUnit testing --- .../java/world/bentobox/bentobox/managers/IslandsManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java b/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java index ed9ed6131..b40df3567 100644 --- a/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java +++ b/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java @@ -1646,7 +1646,8 @@ public class IslandsManager { * @param island - island */ public static void updateIsland(Island island) { - if (handler.objectExists(island.getUniqueId())) { + // When mocking, handler can be null so this null check avoids errors + if (handler != null && handler.objectExists(island.getUniqueId())) { island.clearChanged(); handler.saveObjectAsync(island) .thenAccept(b -> MultiLib.notify("bentobox-updateIsland", island.getUniqueId()));