fix(cache): update entity strategies and MicrobotPlugin for worldview…#1605
fix(cache): update entity strategies and MicrobotPlugin for worldview…#1605Voxsylvae wants to merge 1 commit intochsami:developmentfrom
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe changes refactor the MicrobotPlugin cache initialization and event handling flow, along with updates to entity update strategies. In MicrobotPlugin, Rs2RunePouch is now unconditionally updated on login, with cache event handlers registered only if the cache is enabled and handlers not yet registered. The entity update strategies (GroundItemUpdateStrategy, NpcUpdateStrategy, ObjectUpdateStrategy) are refactored to consistently derive WorldView from either the local player or the top-level WorldView, reducing reliance on potentially-null player context. ObjectUpdateStrategy additionally introduces a ScheduledExecutorService for asynchronous background processing. Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/ObjectUpdateStrategy.java (1)
104-106: Consider using debug level for diagnostic logging.The diagnostic messages at lines 104-106 use
log.info(), which may be too verbose for production environments. These appear to be diagnostic messages that would be more appropriate at debug level.- if(executorService == null || executorService.isShutdown()) log.info ( " executorService is null or shutdown"); - if(Microbot.getClient() == null) log.info ( " Microbot client is null"); - log.info("ObjectUpdateStrategy is shut down, ignoring event: {}", event.getClass().getSimpleName()); + if(executorService == null || executorService.isShutdown()) log.debug("executorService is null or shutdown"); + if(Microbot.getClient() == null) log.debug("Microbot client is null"); + log.debug("ObjectUpdateStrategy is shut down, ignoring event: {}", event.getClass().getSimpleName());
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/MicrobotPlugin.java(4 hunks)runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/GroundItemUpdateStrategy.java(3 hunks)runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/NpcUpdateStrategy.java(2 hunks)runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/ObjectUpdateStrategy.java(4 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/**/*.java
📄 CodeRabbit inference engine (AGENTS.md)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/**/*.java: Place all gameplay automation code under runelite-client/src/main/java/net/runelite/client/plugins/microbot
Prefix configuration interfaces with the plugin name (e.g., ExampleConfig) within microbot plugins
Files:
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/NpcUpdateStrategy.javarunelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/ObjectUpdateStrategy.javarunelite-client/src/main/java/net/runelite/client/plugins/microbot/MicrobotPlugin.javarunelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/GroundItemUpdateStrategy.java
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/**/*.java
📄 CodeRabbit inference engine (AGENTS.md)
Put shared helpers under .../microbot/util
Files:
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/NpcUpdateStrategy.javarunelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/ObjectUpdateStrategy.javarunelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/GroundItemUpdateStrategy.java
**/*.java
📄 CodeRabbit inference engine (AGENTS.md)
**/*.java: Use tabs for indentation, follow the brace placement style exemplified in MicrobotPlugin.java, and keep lines under 120 characters
Use UpperCamelCase for types and lowerCamelCase for members
Files:
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/NpcUpdateStrategy.javarunelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/ObjectUpdateStrategy.javarunelite-client/src/main/java/net/runelite/client/plugins/microbot/MicrobotPlugin.javarunelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/GroundItemUpdateStrategy.java
runelite-client/src/main/java/net/runelite/client/plugins/microbot/MicrobotPlugin.java
📄 CodeRabbit inference engine (AGENTS.md)
When adding panel controls or overlays, update the Microbot navigation panel setup in MicrobotPlugin and provide default config values
Files:
runelite-client/src/main/java/net/runelite/client/plugins/microbot/MicrobotPlugin.java
🧠 Learnings (9)
📓 Common learnings
Learnt from: CR
Repo: chsami/Microbot PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-16T17:14:29.778Z
Learning: Applies to runelite-client/src/main/java/net/runelite/client/plugins/microbot/**/*.java : Place all gameplay automation code under runelite-client/src/main/java/net/runelite/client/plugins/microbot
Learnt from: CR
Repo: chsami/Microbot PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-16T17:14:29.778Z
Learning: Applies to runelite-client/src/main/java/net/runelite/client/plugins/microbot/MicrobotPlugin.java : When adding panel controls or overlays, update the Microbot navigation panel setup in MicrobotPlugin and provide default config values
Learnt from: CR
Repo: chsami/Microbot PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-16T17:14:29.778Z
Learning: Applies to runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/**/*.java : Put shared helpers under .../microbot/util
Learnt from: CR
Repo: chsami/Microbot PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-16T17:14:29.778Z
Learning: Applies to runelite-client/src/main/java/net/runelite/client/plugins/microbot/**/*.java : Prefix configuration interfaces with the plugin name (e.g., ExampleConfig) within microbot plugins
Learnt from: CR
Repo: chsami/Microbot PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-16T17:14:29.778Z
Learning: Applies to runelite-client/src/main/java/net/runelite/client/plugins/microbot/@(!(util|example))/**/*.java : For new automation scripts, reuse the scheduler pattern demonstrated in ExampleScript
Learnt from: g-mason0
Repo: chsami/Microbot PR: 1423
File: runelite-client/src/main/java/net/runelite/client/plugins/microbot/externalplugins/MicrobotPluginManager.java:366-389
Timestamp: 2025-08-23T16:17:37.615Z
Learning: The ScheduledExecutorService injected into MicrobotPluginManager (and other RuneLite classes) is configured as a single-threaded executor via Executors.newSingleThreadScheduledExecutor() at RuneLiteModule.java line 130, wrapped in ExecutorServiceExceptionLogger. This ensures all async tasks execute sequentially, preventing race conditions.
Learnt from: g-mason0
Repo: chsami/Microbot PR: 1462
File: runelite-client/src/main/java/net/runelite/client/plugins/microbot/ui/MicrobotPluginHubPanel.java:343-344
Timestamp: 2025-09-03T03:59:10.180Z
Learning: In MicrobotPluginManager, the public methods installPlugin(), removePlugin(), and update() already use executor.submit() internally to perform their operations asynchronously, making them non-blocking on the EDT. These are wrapper methods that delegate to the actual implementation methods (install(), remove(), refresh()) via the executor.
📚 Learning: 2025-10-16T17:14:29.778Z
Learnt from: CR
Repo: chsami/Microbot PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-16T17:14:29.778Z
Learning: Applies to runelite-client/src/main/java/net/runelite/client/plugins/microbot/**/*.java : Place all gameplay automation code under runelite-client/src/main/java/net/runelite/client/plugins/microbot
Applied to files:
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/NpcUpdateStrategy.javarunelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/ObjectUpdateStrategy.javarunelite-client/src/main/java/net/runelite/client/plugins/microbot/MicrobotPlugin.javarunelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/GroundItemUpdateStrategy.java
📚 Learning: 2025-10-16T17:14:29.778Z
Learnt from: CR
Repo: chsami/Microbot PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-16T17:14:29.778Z
Learning: Applies to runelite-client/src/main/java/net/runelite/client/plugins/microbot/@(!(util|example))/**/*.java : For new automation scripts, reuse the scheduler pattern demonstrated in ExampleScript
Applied to files:
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/NpcUpdateStrategy.javarunelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/ObjectUpdateStrategy.javarunelite-client/src/main/java/net/runelite/client/plugins/microbot/MicrobotPlugin.javarunelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/GroundItemUpdateStrategy.java
📚 Learning: 2025-10-16T17:14:29.778Z
Learnt from: CR
Repo: chsami/Microbot PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-16T17:14:29.778Z
Learning: Applies to runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/**/*.java : Put shared helpers under .../microbot/util
Applied to files:
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/NpcUpdateStrategy.javarunelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/ObjectUpdateStrategy.javarunelite-client/src/main/java/net/runelite/client/plugins/microbot/MicrobotPlugin.javarunelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/GroundItemUpdateStrategy.java
📚 Learning: 2025-10-16T17:14:29.778Z
Learnt from: CR
Repo: chsami/Microbot PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-16T17:14:29.778Z
Learning: Applies to runelite-client/src/main/java/net/runelite/client/plugins/microbot/MicrobotPlugin.java : When adding panel controls or overlays, update the Microbot navigation panel setup in MicrobotPlugin and provide default config values
Applied to files:
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/NpcUpdateStrategy.javarunelite-client/src/main/java/net/runelite/client/plugins/microbot/MicrobotPlugin.java
📚 Learning: 2025-08-23T16:17:37.615Z
Learnt from: g-mason0
Repo: chsami/Microbot PR: 1423
File: runelite-client/src/main/java/net/runelite/client/plugins/microbot/externalplugins/MicrobotPluginManager.java:366-389
Timestamp: 2025-08-23T16:17:37.615Z
Learning: The ScheduledExecutorService injected into MicrobotPluginManager (and other RuneLite classes) is configured as a single-threaded executor via Executors.newSingleThreadScheduledExecutor() at RuneLiteModule.java line 130, wrapped in ExecutorServiceExceptionLogger. This ensures all async tasks execute sequentially, preventing race conditions.
Applied to files:
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/ObjectUpdateStrategy.java
📚 Learning: 2025-09-03T03:59:10.180Z
Learnt from: g-mason0
Repo: chsami/Microbot PR: 1462
File: runelite-client/src/main/java/net/runelite/client/plugins/microbot/ui/MicrobotPluginHubPanel.java:343-344
Timestamp: 2025-09-03T03:59:10.180Z
Learning: In MicrobotPluginManager, the public methods installPlugin(), removePlugin(), and update() already use executor.submit() internally to perform their operations asynchronously, making them non-blocking on the EDT. These are wrapper methods that delegate to the actual implementation methods (install(), remove(), refresh()) via the executor.
Applied to files:
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/ObjectUpdateStrategy.java
📚 Learning: 2025-10-16T17:14:29.778Z
Learnt from: CR
Repo: chsami/Microbot PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-16T17:14:29.778Z
Learning: Applies to runelite-client/src/main/java/net/runelite/client/plugins/microbot/example/**/*.java : Keep runnable examples under .../microbot/example
Applied to files:
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/ObjectUpdateStrategy.javarunelite-client/src/main/java/net/runelite/client/plugins/microbot/MicrobotPlugin.java
📚 Learning: 2025-10-16T17:14:29.778Z
Learnt from: CR
Repo: chsami/Microbot PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-16T17:14:29.778Z
Learning: Applies to runelite-client/src/main/java/net/runelite/client/plugins/microbot/**/*.java : Prefix configuration interfaces with the plugin name (e.g., ExampleConfig) within microbot plugins
Applied to files:
runelite-client/src/main/java/net/runelite/client/plugins/microbot/MicrobotPlugin.java
🧬 Code graph analysis (2)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/ObjectUpdateStrategy.java (3)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/GroundItemUpdateStrategy.java (1)
Slf4j(30-543)runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/NpcUpdateStrategy.java (1)
Slf4j(27-396)runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/Rs2ObjectCache.java (1)
Slf4j(33-604)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/MicrobotPlugin.java (1)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/inventory/Rs2RunePouch.java (1)
Rs2RunePouch(32-626)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build
🔇 Additional comments (7)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/NpcUpdateStrategy.java (1)
205-223: LGTM! WorldView fallback logic is robust.The conditional WorldView resolution properly handles the case where the local player is null by falling back to the top-level WorldView. The subsequent NPC iteration correctly uses the resolved WorldView reference. This aligns with the PR's objective to improve robustness during world transitions.
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/GroundItemUpdateStrategy.java (2)
60-60: LGTM! Premature isLoggedIn check removed.The simplified validation now only checks executorService state and client presence, removing the premature isLoggedIn() guard that could cause events to be rejected unnecessarily. This aligns with the PR's objective to prevent missed cache updates during different game states.
217-247: LGTM! WorldView fallback implemented consistently.The WorldView resolution and scene access logic properly handles null player cases by falling back to the top-level WorldView. All scene-related operations (getScene, getPlane) consistently use the resolved WorldView reference.
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/ObjectUpdateStrategy.java (2)
63-69: LGTM! Asynchronous executor properly initialized.The constructor initializes a ScheduledExecutorService for background processing, following the pattern established in GroundItemUpdateStrategy and NpcUpdateStrategy. This enables non-blocking scene scan operations.
248-258: LGTM! WorldView fallback properly implemented.The WorldView resolution follows the established pattern of falling back to the top-level WorldView when the player is null, ensuring scene access remains available during world transitions.
runelite-client/src/main/java/net/runelite/client/plugins/microbot/MicrobotPlugin.java (2)
309-315: LGTM! Cache initialization properly guarded against double initialization.The unconditional
Rs2RunePouch.fullUpdate()ensures rune pouch state is refreshed on login regardless of cache settings. The subsequent check forisEventHandlersRegistered()prevents double initialization of cache event handlers, with an early return that skips region update logic during the first login. This aligns with the PR's objective to prevent double initialization.
328-330: LGTM! Event handler cleanup properly guarded.The unregistration of cache event handlers is properly guarded by checking both that the cache is enabled and that the handlers are currently registered, ensuring cleanup only occurs when necessary.
...va/net/runelite/client/plugins/microbot/util/cache/strategy/entity/ObjectUpdateStrategy.java
Outdated
Show resolved
Hide resolved
bc150b3 to
40f9374
Compare
Improves robustness of object and ground item cache updates by:
Adding fallback to top-level WorldView when player WorldView scene is null
Removing premature isLoggedIn() checks that caused event rejection
Preventing double initialization of cache event handlers
Adding diagnostic logging for cache system states
Fixes null pointer exceptions and missed cache updates during world transitions and different game states.
Files changed:
ObjectUpdateStrategy.java
GroundItemUpdateStrategy.java
MicrobotPlugin.java