Skip to content

Comments

fix(cache): update entity strategies and MicrobotPlugin for worldview…#1605

Closed
Voxsylvae wants to merge 1 commit intochsami:developmentfrom
Voxsylvae:fix/cache-strategy-worldview-handling
Closed

fix(cache): update entity strategies and MicrobotPlugin for worldview…#1605
Voxsylvae wants to merge 1 commit intochsami:developmentfrom
Voxsylvae:fix/cache-strategy-worldview-handling

Conversation

@Voxsylvae
Copy link
Contributor

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 11, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The 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

  • 2.0.17 #1549: Modifies Rs2RunePouch load logic while this PR invokes Rs2RunePouch.fullUpdate() during login flow
  • 2.0.8 #1528: Alters cache initialization and event handler registration logic that directly relates to this PR's changes in MicrobotPlugin and cache event handling
  • 2.0.9 #1530: Makes Microbot.isRs2CacheEnabled publicly accessible, which this PR conditionally checks throughout the cache event handler logic

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: updating entity strategies and MicrobotPlugin for worldview handling, which aligns with the primary objective of improving cache robustness through worldview-related fixes.
Description check ✅ Passed The description is directly related to the changeset, providing specific details about the improvements (fallback worldview handling, removal of premature checks, preventing double initialization) and listing the modified files.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7a56273 and bc150b3.

📒 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.java
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/ObjectUpdateStrategy.java
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/MicrobotPlugin.java
  • runelite-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.java
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/ObjectUpdateStrategy.java
  • runelite-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.java
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/ObjectUpdateStrategy.java
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/MicrobotPlugin.java
  • runelite-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.java
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/ObjectUpdateStrategy.java
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/MicrobotPlugin.java
  • runelite-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.java
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/ObjectUpdateStrategy.java
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/MicrobotPlugin.java
  • runelite-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.java
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/cache/strategy/entity/ObjectUpdateStrategy.java
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/MicrobotPlugin.java
  • runelite-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.java
  • runelite-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.java
  • runelite-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 for isEventHandlersRegistered() 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.

@Voxsylvae Voxsylvae force-pushed the fix/cache-strategy-worldview-handling branch from bc150b3 to 40f9374 Compare November 11, 2025 20:29
@chsami chsami closed this Nov 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants