Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,63 @@ public interface AutoLoginConfig extends Config {
@ConfigItem(
keyName = "Is Member",
name = "Is Member",
description = "use Member worlds",
position = 0,
description = "Use member worlds",
position = 1,
section = generalSection
)
default boolean isMember() { return false; }

@ConfigItem(
keyName = "RandomWorld",
name = "RandomWorld",
description = "use random worlds",
position = 0,
name = "Use Random World",
description = "Use random worlds",
position = 2,
section = generalSection
)
default boolean useRandomWorld() { return true; }

@ConfigSection(
name = "Region Filter",
description = "Filter random world selection by region",
position = 10,
closedByDefault = false
)
String regionSection = "region";


@ConfigItem(
keyName = "AllowUK",
name = "UK",
description = "Allow UK worlds",
position = 1,
section = regionSection
)
default boolean allowUK() { return true; }

@ConfigItem(
keyName = "AllowUS",
name = "US",
description = "Allow US worlds",
position = 2,
section = regionSection
)
default boolean allowUS() { return true; }

@ConfigItem(
keyName = "AllowGermany",
name = "Germany",
description = "Allow German worlds",
position = 3,
section = regionSection
)
default boolean allowGermany() { return true; }

@ConfigItem(
keyName = "AllowAustralia",
name = "Australia",
description = "Allow Australian worlds",
position = 4,
section = regionSection
)
default boolean allowAustralia() { return true; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,65 @@
import net.runelite.api.GameState;
import net.runelite.client.plugins.microbot.Microbot;
import net.runelite.client.plugins.microbot.Script;
import net.runelite.client.plugins.microbot.breakhandler.BreakHandlerScript;
import net.runelite.client.plugins.microbot.util.security.Login;
import net.runelite.http.api.worlds.WorldRegion;
import org.slf4j.event.Level;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.TimeUnit;

public class AutoLoginScript extends Script {

private List<WorldRegion> getAllowedRegions(AutoLoginConfig config) {
List<WorldRegion> allowedRegions = new ArrayList<>();

if (config.allowUK()) {
allowedRegions.add(WorldRegion.UNITED_KINGDOM);
}
if (config.allowUS()) {
allowedRegions.add(WorldRegion.UNITED_STATES_OF_AMERICA);
}
Comment on lines +24 to +26
Copy link
Contributor

@coderabbitai coderabbitai bot Aug 30, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

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.

Suggested change
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.

Copy link
Contributor

Choose a reason for hiding this comment

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

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");**

Copy link
Contributor

Choose a reason for hiding this comment

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

@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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sit robot

Copy link
Contributor

Choose a reason for hiding this comment

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

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!

if (config.allowGermany()) {
allowedRegions.add(WorldRegion.GERMANY);
}
if (config.allowAustralia()) {
allowedRegions.add(WorldRegion.AUSTRALIA);
}

return allowedRegions;
}

private int getRandomWorldWithRegionFilter(AutoLoginConfig config) {
List<WorldRegion> allowedRegions = getAllowedRegions(config);

if (allowedRegions.isEmpty()) {
// If no regions allowed, use default method
return Login.getRandomWorld(config.isMember());
}

// Pick a random region from allowed regions
Random random = new Random();
WorldRegion selectedRegion = allowedRegions.get(random.nextInt(allowedRegions.size()));

return Login.getRandomWorld(config.isMember(), selectedRegion);
}

public boolean run(AutoLoginConfig autoLoginConfig) {
mainScheduledFuture = scheduledExecutorService.scheduleWithFixedDelay(() -> {
try {
if (!super.run()) return;
if (BreakHandlerScript.isBreakActive() || BreakHandlerScript.isMicroBreakActive()) return;

if (Microbot.getClient().getGameState() == GameState.LOGIN_SCREEN) {
if (autoLoginConfig.useRandomWorld()) {
new Login(Login.getRandomWorld(autoLoginConfig.isMember()));
final int world = getRandomWorldWithRegionFilter(autoLoginConfig);
Microbot.log(Level.INFO, String.format("Auto-logging into random %s world: %d", autoLoginConfig.isMember() ? "member" : "free", world));
new Login(world);
} else {
Microbot.log(Level.INFO, String.format("Auto-logging into world: %d", autoLoginConfig.world()));
new Login(autoLoginConfig.world());
}
sleep(5000);
Expand Down