autologin region filters#1448
Conversation
…#1440) * feat(sandminer): drop empty waterskins when humidify is disabled * refactor(sandminer): drop empty waterskins only when idle and drop all --------- Co-authored-by: Pert <your.email@example.com>
…chsami#1440)" This reverts commit 8da3f86.
config changes
script updated to select world hop configs
WalkthroughAdds a "Region Filter" config section with UK/US/Germany/Australia toggles and integrates region-aware random world selection into AutoLoginScript; falls back when no regions allowed, adds break checks, logs choices, and sleeps 5000 ms after login. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User
participant S as AutoLoginScript
participant C as AutoLoginConfig
participant L as Login API
U->>S: Trigger AutoLogin
S->>C: Read isMember(), useRandomWorld(), region toggles
alt useRandomWorld() == true
rect rgba(200,230,255,0.3)
S->>S: check BreakHandlerScript.isBreakActive()/isMicroBreakActive()
opt not on break
S->>S: getAllowedRegions(C)
alt allowed regions not empty
S->>S: pick random region
S->>L: getRandomWorld(isMember, selectedRegion)
else no regions allowed
S->>L: getRandomWorld(isMember) /* legacy */
end
S->>L: Login(selectedWorld)
S->>S: sleep(5000 ms)
end
end
else useRandomWorld() == false
S->>L: Login(configured world)
end
L-->>S: Login result
S-->>U: Continue flow
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/accountselector/AutoLoginScript.java (2)
35-48: Use ThreadLocalRandom and add a lightweight fallback logAvoid constructing Random per call; ThreadLocalRandom is cheaper and thread-safe. Also emit a debug log on empty filter to aid support.
private int getRandomWorldWithRegionFilter(AutoLoginConfig config) { List<WorldRegion> allowedRegions = getAllowedRegions(config); if (allowedRegions.isEmpty()) { - // If no regions allowed, use default method + // No regions allowed — falling back to default random world + Microbot.log("AutoLogin: no regions allowed; using default random world selection"); return Login.getRandomWorld(config.isMember()); } // Pick a random region from allowed regions - Random random = new Random(); - WorldRegion selectedRegion = allowedRegions.get(random.nextInt(allowedRegions.size())); + WorldRegion selectedRegion = allowedRegions.get(java.util.concurrent.ThreadLocalRandom.current().nextInt(allowedRegions.size())); return Login.getRandomWorld(config.isMember(), selectedRegion); }
61-61: Make the 5s post-login delay configurableHardcoded 5000ms can be too long/short depending on latency. Consider a config item (e.g., postLoginDelayMs) with a sane default.
runelite-client/src/main/java/net/runelite/client/plugins/microbot/accountselector/AutoLoginConfig.java (1)
45-88: Region filter section and toggles look solid; consider conditional visibilityDefaults to true and clear naming are good. If supported by your config framework, conditionally show this section only when Use Random World is enabled to reduce UI noise.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/accountselector/AutoLoginConfig.java(1 hunks)runelite-client/src/main/java/net/runelite/client/plugins/microbot/accountselector/AutoLoginScript.java(1 hunks)
🔇 Additional comments (2)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/accountselector/AutoLoginScript.java (1)
57-57: Verified getRandomWorld(boolean, WorldRegion) overload exists
Foundpublic static int getRandomWorld(boolean isMembers, WorldRegion region)inutil/security/Login.javausing the samenet.runelite.http.api.worlds.WorldRegionimport.runelite-client/src/main/java/net/runelite/client/plugins/microbot/accountselector/AutoLoginConfig.java (1)
30-41: Text/position tweaks look goodCopy edits and ordering under General section are fine.
| if (config.allowUS()) { | ||
| allowedRegions.add(WorldRegion.UNITED_STATES_OF_AMERICA); | ||
| } |
There was a problem hiding this comment.
Fix likely wrong enum constant for US region
WorldRegion probably exposes UNITED_STATES, not UNITED_STATES_OF_AMERICA. As-is this will fail to compile.
- if (config.allowUS()) {
- allowedRegions.add(WorldRegion.UNITED_STATES_OF_AMERICA);
- }
+ if (config.allowUS()) {
+ allowedRegions.add(WorldRegion.UNITED_STATES);
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (config.allowUS()) { | |
| allowedRegions.add(WorldRegion.UNITED_STATES_OF_AMERICA); | |
| } | |
| if (config.allowUS()) { | |
| allowedRegions.add(WorldRegion.UNITED_STATES); | |
| } |
🤖 Prompt for AI Agents
In
runelite-client/src/main/java/net/runelite/client/plugins/microbot/accountselector/AutoLoginScript.java
around lines 22 to 24, the enum constant WorldRegion.UNITED_STATES_OF_AMERICA is
incorrect and causes a compile error; replace it with the actual enum constant
used by WorldRegion (likely WorldRegion.UNITED_STATES), update any imports if
necessary, then rebuild to verify compilation; if unsure, open the WorldRegion
enum to confirm the exact constant name and use that.
There was a problem hiding this comment.
UNITED_STATES_OF_AMERICA
is the correct world region.
public enum WorldRegion {
UNITED_STATES_OF_AMERICA("US", "USA"),
UNITED_KINGDOM("GB", "GBR"),
AUSTRALIA("AU", "AUS"),
GERMANY("DE", "DEU");**
There was a problem hiding this comment.
@T-edit Thank you for the correction! You're absolutely right - UNITED_STATES_OF_AMERICA is indeed the correct enum constant in the WorldRegion enum. I apologize for the incorrect suggestion. The original code in the diff is correct as written.
I appreciate you providing the actual enum definition to clarify this. The code should compile without any issues.
✏️ Learnings added
Learnt from: T-edit
PR: chsami/Microbot#1448
File: runelite-client/src/main/java/net/runelite/client/plugins/microbot/accountselector/AutoLoginScript.java:22-24
Timestamp: 2025-08-30T15:17:12.028Z
Learning: In the RuneLite codebase, the WorldRegion enum constants are: UNITED_STATES_OF_AMERICA, UNITED_KINGDOM, AUSTRALIA, and GERMANY. The US region constant is specifically UNITED_STATES_OF_AMERICA, not UNITED_STATES.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
There was a problem hiding this comment.
Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!
...ient/src/main/java/net/runelite/client/plugins/microbot/accountselector/AutoLoginScript.java
Show resolved
Hide resolved
...ient/src/main/java/net/runelite/client/plugins/microbot/accountselector/AutoLoginScript.java
Show resolved
Hide resolved
...ient/src/main/java/net/runelite/client/plugins/microbot/accountselector/AutoLoginScript.java
Outdated
Show resolved
Hide resolved
...ient/src/main/java/net/runelite/client/plugins/microbot/accountselector/AutoLoginScript.java
Show resolved
Hide resolved
…obot/accountselector/AutoLoginScript.java Co-authored-by: Igor <74077743+Bolado@users.noreply.github.com>
…obot/accountselector/AutoLoginScript.java Co-authored-by: Igor <74077743+Bolado@users.noreply.github.com>
…obot/accountselector/AutoLoginScript.java Co-authored-by: Igor <74077743+Bolado@users.noreply.github.com>
…obot/accountselector/AutoLoginScript.java Co-authored-by: Igor <74077743+Bolado@users.noreply.github.com>
|
@v3tcn - please resolve the build error. |
...ient/src/main/java/net/runelite/client/plugins/microbot/accountselector/AutoLoginScript.java
Show resolved
Hide resolved
import org.slf4j.event.Level; Co-authored-by: Igor <74077743+Bolado@users.noreply.github.com>
Re-added changes from:
https://github.com/chsami/Microbot/pull/1346/files
#1346 (comment)
For Auto login
Without adding the breakhandler switches
Summary by CodeRabbit
New Features
Style
Bug Fixes