-
-
Notifications
You must be signed in to change notification settings - Fork 497
autologin region filters #1448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
autologin region filters #1448
Changes from all commits
0d2a385
ec99d87
13af940
8da3f86
f66fc28
9e635ef
5ffb8e1
f37121c
c515a2e
ccbfe8f
e5fcccf
99f517f
323c4a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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; | ||||||||||||||
v3tcn marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
| 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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
Suggested change
🤖 Prompt for AI Agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. UNITED_STATES_OF_AMERICA is the correct world region. public enum WorldRegion {
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @T-edit Thank you for the correction! You're absolutely right - I appreciate you providing the actual enum definition to clarify this. The code should compile without any issues. ✏️ Learnings added
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sit robot
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||
| 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; | ||||||||||||||
v3tcn marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
| 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()); | ||||||||||||||
v3tcn marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
| } | ||||||||||||||
| sleep(5000); | ||||||||||||||
|
|
||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.