Jump to content

Custom Break Handler?


dubai

Recommended Posts

Hi, i'm currently implementing a custom break handler in my scripts. This can be configured in the scriptGUI. all the logic seems to work apart from getting it to log back in?
Can't see anything relevant in the api documentation or I'm not looking in the right places... Any help would be appreciated!

In particular:

Cannot resolve symbol 'LOGIN'

api.getTabs().open(Tab.LOGIN);

Here's might BreakHandler class:

package extraFeatures;

import org.osbot.rs07.api.ui.Tab;
import org.osbot.rs07.script.MethodProvider;

import java.util.Random;

public class BreakHandler {

    private final MethodProvider api;
    private final int minBotTime;
    private final int maxBotTime;
    private final int minBreakTime;
    private final int maxBreakTime;
    private long nextBreakTime;
    private final Random random;

    public BreakHandler(MethodProvider api, int minBotTime, int maxBotTime, int minBreakTime, int maxBreakTime) {
        this.api = api;
        this.minBotTime = minBotTime;
        this.maxBotTime = maxBotTime;
        this.minBreakTime = minBreakTime;
        this.maxBreakTime = maxBreakTime;
        this.random = new Random();
        scheduleNextBreak();
    }

    private void scheduleNextBreak() {
        long botTime = random.nextInt(maxBotTime - minBotTime + 1) + minBotTime;
        nextBreakTime = System.currentTimeMillis() + botTime * 60000L;
    }

    public boolean shouldTakeBreak() {
        return System.currentTimeMillis() >= nextBreakTime;
    }

    public void takeBreak() throws InterruptedException {
        long breakTime = random.nextInt(maxBreakTime - minBreakTime + 1) + minBreakTime;
        api.log("Taking a break for " + breakTime + " minutes.");
        api.getTabs().open(Tab.LOGOUT);
        MethodProvider.sleep(breakTime * 60000L);
        api.log("Break over, logging back in.");
        api.getTabs().open(Tab.LOGIN);                /// THIS LINE NEEDS TO CHANGE?
        scheduleNextBreak();
    }
}
Edited by dubai
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...