Repository navigation
fix(MahoganyHomes): guard null home and player location in walkToHome and bank (0.0.15) - #649
Merged
chsami merged 1 commit intoOct 17, 2026
Conversation
… and bank (0.0.15) walkToHome and bank null-checked a local copy of the current home but then re-read plugin.getCurrentHome() through isMissingItems, planksNeeded and steelBarsNeeded and for the walk target, so a contract cleared on the client thread mid-loop threw an NPE. Rs2Player.getWorldLocation() was also passed to distanceBetween unchecked. Snapshot both once, guard them in isAwayFromHome, and pass the Home through to the material helpers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LjtEMzQHGuq4M1Mpqk9pPV
3 tasks done
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 shows two NullPointerExceptions thrown from
MahoganyHomesScript.walkToHome, logged as "Mahogany Homes script loop failed" (plugin 0.0.13, Microbot 2.6.33):NullPointerException: Cannot invoke "WorldPoint.getX()" because "point" is nullatMahoganyHomesPlugin.distanceBetween:833<-MahoganyHomesScript.walkToHome:616NullPointerException: Cannot invoke "Home.getRequiredPlanks..."atMahoganyHomesScript.planksNeeded:629<-isMissingItems:624<-walkToHome:617Root cause
walkToHome(andbank()) passRs2Player.getWorldLocation()directly intodistanceBetween, which dereferences the point. The location is null while the game is loading, hopping or logging out. The run loop checks for null at the top, but the value can turn null later in the same tick.walkToHomeandbank()null-check a local copy ofcurrentHome, butisMissingItems -> planksNeeded/steelBarsNeededand the walk target readplugin.getCurrentHome()again. The client thread clears that field withapplyCurrentHome(null)when a contract finishes or is cleared, so the second read can return null.Change
MahoganyHomesScript.java:isAwayFromHome(Home, WorldPoint). It returnshome != null && playerLocation != null && distanceBetween(...) > 0.bank()andwalkToHome()each read the home and the player location once and pass them to this helper.isMissingItems,planksNeededandsteelBarsNeedednow take theHomeas a parameter. Every call passes the local copy, andwalkToHomewalks tocurrentHome.getLocation().MahoganyHomesPlugin.java: version 0.0.14 -> 0.0.15.Validation
./gradlew test --tests '*MahoganyHomesScriptTest' --tests '*PluginManifestVersionTest' -PpluginList=MahoganyHomesPlugin-> BUILD SUCCESSFULMahoganyHomesScriptTest: 4 tests (2 new), 0 failures. The new tests check that a null home or null location givesfalse, and that a point outsideHome.JESScounts as away while a point inside its area on another plane does not.PluginManifestVersionTest: 1 test, 0 failures.Known gaps
isAwayFromHome. They do not cover the cross-thread race behind group 2517. That race is fixed by reading the home once and passing it down.readyFurniture(null check, then the lambda readsgetCurrentHome()again),getFixableObjects,fix()andfinish().readyFurnitureis also the stop condition ofwalkWithStateUntilinwalkToHome. None of the reported stack traces go through these paths. A follow-up could read the home once there too.🤖 Generated with Claude Code
https://claude.ai/code/session_01LjtEMzQHGuq4M1Mpqk9pPV