Repository navigation
fix(AmmoniteCrabs): guard null local player location during hop or load (1.1.7) - #642
Merged
chsami merged 1 commit intoOct 16, 2026
Conversation
…ad (1.1.7) Read the player location through Rs2Player.getWorldLocation() and skip the check when it is null, instead of dereferencing getLocalPlayer() inside client-thread lambdas in preStateChecks, scanAmmoniteCrabLocation, walkBack, resetAggro and otherPlayerDetected. Use Rs2Player.isInteracting() in the FIGHT case. 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 groups 2331 and 2332 come from AmmoniteCrabPlugin 1.1.6 on Microbot 2.6.33. They had 6 occurrences in total (3 + 3) in one session, about every 5 minutes. Both are:
AmmoniteCrabScript.lambda$walkBack$4:211(insideClientThread.invokefromHooks.tick)AmmoniteCrabScript.lambda$otherPlayerDetected$8:276(same path)Root cause
The script read the player position with
Microbot.getClientThread().invoke(() -> Microbot.getClient().getLocalPlayer().getWorldLocation())and never checked for null, at lines 135, 181, 211 (walkBack), 259 (resetAggro) and 276 (otherPlayerDetected). Line 49 also calledgetLocalPlayer().isInteracting()without a check. While the client is logging out, loading or hopping worlds,getLocalPlayer()returns null, and the lambda throws on the client thread.Change
Rs2Player.getWorldLocation(). That call is null-safe because it uses the state cache andrunOnClientThreadOptional.preStateChecksonly applies the "more than 10 tiles from the hop spot" rule when the location is known.scanAmmoniteCrabLocationskips the tick when the location is null.walkBack,resetAggroand the<= 3check in the scan use a new helper,isWithin(WorldPoint, WorldPoint, int), which returns false for a null location.otherPlayerDetected(WorldPoint)returns false for a null location.Rs2Player.isInteracting(). ItsdistanceTo(...) > 0check now has the same null guard, so the fix does not leave a new NPE next to the fixed sites.Validation
AmmoniteCrabScriptTesthas 3 tests: a null location is never within range, the range boundary works with real points, andotherPlayerDetected(null)returns false without asking for players. All 3 pass.PluginManifestVersionTestpasses../gradlew build -x test -PpluginList=AmmoniteCrabPluginsucceeds.Known gaps
otherPlayerDetected()returns false, sohijackTimerresets. A hop caused by a hijack can then be delayed by about one tick. This is minor and intended.🤖 Generated with Claude Code
https://claude.ai/code/session_01LjtEMzQHGuq4M1Mpqk9pPV