Repository navigation
fix(GotrPlugin): guard region checks against null player location (1.5.11) - #659
Merged
chsami merged 2 commits intoOct 19, 2026
Merged
Conversation
…5.11) isInHugeMine, isInLargeMine, isOutsideBarrier and isInMainRegion dereferenced Rs2Player.getWorldLocation() without a null check, so the usePortal sleepUntil threw an NPE while the region loaded after the portal teleport. Read the location once, return false when it is null, and use its X coordinate instead of a client-thread lookup on getLocalPlayer(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LjtEMzQHGuq4M1Mpqk9pPV
The region predicates now return false for a null location, so the main loop read the region-load window after a portal teleport or altar trip as "not in the minigame" and could click the barrier or reset plugin state. Bail out of the iteration until Rs2Player.getWorldLocation() is known. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LjtEMzQHGuq4M1Mpqk9pPV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Client error telemetry group 2663 (1 report, first and last seen 2026-10-19, Microbot 2.6.34, GotrPlugin 1.5.10, thread
GotrScript-6) logged ajava.lang.NullPointerExceptionfromGlobal Sleep::Root cause
Rs2Player.getWorldLocation()returns null while the local player is unavailable, which happens during the region load that follows a portal teleport into the huge mine (and when entering or leaving an altar).isInHugeMine,isInLargeMine,isOutsideBarrierandisInMainRegionall dereferenced that value without a check, and the client-thread lambdas inisInHugeMineandisInLargeMinealso dereferencedgetLocalPlayer()directly. ThesleepUntil(() -> isInHugeMine())inusePortalpolls exactly while the region is loading, so the predicate threw.Change
isInHugeMine,isInLargeMine,isOutsideBarrierandisInMainRegionread the location once and return false when it is null.isInHugeMineandisInLargeMinetake the X coordinate from that same location instead of a separate client-threadgetLocalPlayer().getWorldLocation()call.static boolean isPlayerLocationKnown(). The main loop returns early (if (!isPlayerLocationKnown()) return;) right aftersuper.run(), so a tick where the location is still unknown is skipped instead of reachingisInMiniGame = !isOutsideBarrier() && isInMainRegion(). Without this, an unknown location would read as "not in the minigame" and the loop could click the barrier (enterMinigame) or callresetPlugin()(waitForMinigameToStart). Skipping the tick is the same outcome the old NPE + catch block produced, minus the error.sleepUntil(isInHugeMine)inusePortal,sleepUntilTrue(isInMainRegion)) now keep polling until the region loads, which fixes the reported stack trace.Validation
./gradlew test --tests 'net.runelite.client.plugins.microbot.gotr.*' build -PpluginList=GotrPluginpasses.GotrRegionCheckTest(6 tests): all four region checks return false for a null location,isPlayerLocationKnown()is false for null and true for a known location. Existing GotR tests (GotrAltarRenderableTest,GotrPluginRoundEventTest,GotrPortalClockTest) pass.Known gaps
checkPouches/repairPouches, which can sleep for ~1.5s. If the location goes null inside that window,isInMiniGamecan still evaluate false for that one tick. The window is narrow (teleports happen inside theusePortal/enterAltarsleeps) and the next tick re-checks at the gate.!isInMainRegion()inenterAltarand!isInHugeMine()inleaveHugeMinenow evaluate true while the location is null, so those waits can end early. This is not a regression: previouslyGlobal.sleepUntilcaught the NPE and returned false immediately, and the next tick re-checks.🤖 Generated with Claude Code
https://claude.ai/code/session_01LjtEMzQHGuq4M1Mpqk9pPV