Skip to content

Introduce Rs2Player.isIdle() and waitForXpDrop() overloads#1779

Draft
afss0 wants to merge 4 commits into
chsami:developmentfrom
afss0:introduceIsIdle
Draft

Introduce Rs2Player.isIdle() and waitForXpDrop() overloads#1779
afss0 wants to merge 4 commits into
chsami:developmentfrom
afss0:introduceIsIdle

Conversation

@afss0
Copy link
Copy Markdown
Contributor

@afss0 afss0 commented May 18, 2026

This PR introduces:

  1. Skill unspecific waitForXpDrop overloads, that triggers when the player receives experience in any skill.
  2. Rs2Player.isIdle(), to check if the player is idle (not performing any action).

The player is considered idle if all of the following are true:

  • Not currently animating (animation is IDLE and no animation within the last 3000ms)
  • Not in combat
  • Not moving
  • Not interacting with a bank, deposit box, grand exchange, or chat dialog

Microbot Updater and others added 4 commits May 17, 2026 22:45
- Add waitForXpDrop() overloads that monitor overall XP drop (any skill)
  to complement existing skill-specific variants
- Add isIdle() method that checks if the player is idle by verifying:
  no recent animation, no combat, no movement, no bank/deposit box/
  grand exchange/dialogue interactions, and no XP drop within 3000ms
- Add required imports for Rs2Bank, Rs2DepositBox, Rs2Dialogue,
  Rs2GrandExchange
…er.isIdle()

Replace the two-phase evaluation + waitForXpDrop pattern with a single sleepUntilTrue loop that polls every 100ms for both XP drops and blocking conditions (animation, combat, movement, UI). This eliminates the race condition where a blocking action could start during the wait and go undetected until after the timeout (example: some skilling activities like cooking and smithing have a short idle animation period which could falsely indicate a idle condition, while the action fails to trigger a xp drop in 3 seconds, common when burning food or failing to smelt iron).
…previous, instead of 5 ticks"

This reverts commit 99e32e1.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 18, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 726fcab6-4908-4ead-960f-83684cfc2c40

📥 Commits

Reviewing files that changed from the base of the PR and between 9fda631 and c30f098.

📒 Files selected for processing (1)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/player/Rs2Player.java

Walkthrough

This PR extends the Rs2Player utility class with imports and two new public methods for player state detection. Four UI/state helper imports (Rs2Bank, Rs2DepositBox, Rs2Dialogue, Rs2GrandExchange) are added to support blocking-condition checks. Four overloads of waitForXpDrop are introduced to detect overall experience gains (not per-skill), with optional timeout and inventory-full early-exit parameters. A new isIdle() method polls up to 3 seconds to verify the player is idle by confirming no XP gain, animation, combat, movement, and no open bank/deposit-box/grand-exchange/dialogue screens.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the two main additions: Rs2Player.isIdle() method and waitForXpDrop() overloads.
Description check ✅ Passed The description is directly related to the changeset, clearly explaining the two features being introduced and the idle criteria with specific technical details.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

@afss0 afss0 marked this pull request as draft May 18, 2026 07:03
@afss0
Copy link
Copy Markdown
Contributor Author

afss0 commented May 18, 2026

ClientThreadGuardrailTest claims net.runelite.api.Client#getOverallExperience() requires to be called in the client thread, however I didn't detect any exceptions during runtime. I'll review this further.

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.

1 participant