From e2648b6e544bb67822ef1aed801e00a40a0f7e4a Mon Sep 17 00:00:00 2001 From: g-mason0 <19415334+g-mason0@users.noreply.github.com> Date: Tue, 31 Dec 2024 10:43:24 -0500 Subject: [PATCH] fix: add null checks to quickCanCast --- .../client/plugins/microbot/util/magic/Rs2Magic.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/magic/Rs2Magic.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/magic/Rs2Magic.java index c4e64539c9..7afdab8f9c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/magic/Rs2Magic.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/magic/Rs2Magic.java @@ -94,10 +94,12 @@ public static boolean quickCanCast(MagicAction magicSpell) { Rs2Tab.switchToMagicTab(); sleepUntil(() -> Rs2Tab.getCurrentTab() == InterfaceTab.MAGIC); } - - Widget widget = Rs2Widget.findWidget(magicSpell.getName()); + + Widget spellbookWidget = Rs2Widget.getWidget(218, 3); + if (spellbookWidget == null) return false; + Widget widget = Rs2Widget.findWidget(magicSpell.getName(), List.of(spellbookWidget)); + if (widget == null) return false; return widget.getSpriteId() == magicSpell.getSprite(); - } public static boolean quickCanCast(String spellName) {