From 4f2c5699c278f5f7a9b29aebbab4052f2b9c59e5 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Fri, 5 Jul 2024 11:57:35 +0800 Subject: Fix DisciplineTestHelper heldId NPE --- .../skyblock/crimson/dojo/DisciplineTestHelper.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/DisciplineTestHelper.java b/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/DisciplineTestHelper.java index c01bfd73..ab0a0781 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/DisciplineTestHelper.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/DisciplineTestHelper.java @@ -6,6 +6,7 @@ import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import net.minecraft.client.MinecraftClient; import java.util.Map; +import java.util.Objects; public class DisciplineTestHelper { private static final MinecraftClient CLIENT = MinecraftClient.getInstance(); @@ -41,11 +42,10 @@ public class DisciplineTestHelper { return false; } String heldId = CLIENT.player.getMainHandStack().getSkyblockId(); - if (SWORD_TO_NAME_LOOKUP.containsKey(heldId)) { - - return SWORD_TO_NAME_LOOKUP.get(heldId).equals(name); + if (heldId == null) { + return false; } - return false; + return Objects.equals(SWORD_TO_NAME_LOOKUP.get(heldId), name); } /** @@ -58,6 +58,9 @@ public class DisciplineTestHelper { return 0; } String heldId = CLIENT.player.getMainHandStack().getSkyblockId(); + if (heldId == null) { + return 0; + } return SWORD_TO_COLOR_LOOKUP.getOrDefault(heldId, 0); } } -- cgit