Skip to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Start a break early.

Featured Replies

I want to start a break early. 
This doesn't work. OSB logs "Started random solver : " then immediately calls onExit, skipping BreakManager's onloop. 

package Util;

import org.osbot.rs07.Bot;
import org.osbot.rs07.randoms.BreakManager;

public class BreakManagerHook extends BreakManager {

    private static boolean breakNow = false;

    public BreakManagerHook(Bot IiIiiiIiiII) {
        super(IiIiiiIiiII);
    }


    @Override
    public boolean shouldActivate() {
        if(super.shouldActivate() || breakNow) {
            breakNow = false;
            return true;
        }
        return false;
    }

    @Override
    public void onExit() {
        super.onExit();
        log("Return from break hook!");
    }

    public static void startBreakNow() {
        breakNow = true;
    }
}
  • Author

Ok this seems to work. shouldActivate() gets called multiple times, so I have to "short circuit" it. 
 

@Override
public boolean shouldActivate() {
    if(breakNow) log("Early breaking");
    return super.shouldActivate() || breakNow;
}
  • Developer
19 minutes ago, yfoo said:

I want to start a break early. 
This doesn't work. OSB logs "Started random solver : " then immediately calls onExit, skipping BreakManager's onloop. 

Well the moment it start it also stops as you set it back to false after doing this

 if(super.shouldActivate() || breakNow) {

Are you doing this to have you script break early say, when it's at the bank? Interesting approach if so, I disabled osbots break manager completely and just had it sleep until the break was over then let the login solver log the player back in and continue

  • Author
On 9/3/2024 at 4:43 PM, dubai said:

Are you doing this to have you script break early say, when it's at the bank? Interesting approach if so, I disabled osbots break manager completely and just had it sleep until the break was over then let the login solver log the player back in and continue

Yes, I do not want a break to happen at a certain time. I was working on a blast mining script If there was not enough time remaining before break to do cycle then start the break early. 
 

10 hours ago, yfoo said:

Yes, I do not want a break to happen at a certain time. I was working on a blast mining script If there was not enough time remaining before break to do cycle then start the break early. 
 

Yeah I gotcha, heaps of reasons to add custom breaks tbh.

 

I started doing this but I never finished it... @Czar Where you at 😛

  • Author
4 hours ago, dubai said:

Yeah I gotcha, heaps of reasons to add custom breaks tbh.

 

I started doing this but I never finished it... @Czar Where you at 😛

This was the end result I settled with. I also happened to need a hook to know when the break ended to potentially check if my position was crashed while I was away. The OnExit() allows me to know that. For now I'm not doing anything with it just logging (log("Return from break!");)
 

package Util;

import org.osbot.rs07.Bot;
import org.osbot.rs07.randoms.BreakManager;

public class BreakManagerHook extends BreakManager {

    private volatile boolean breakEarly;
    private volatile boolean shouldActivateCalled;

    private static BreakManagerHook instance;

    public static BreakManagerHook getInstance() {
        if(instance == null) {
            throw new NullPointerException("ExcavatePlantIgnite is null");
        }
        return instance;
    }

    public static BreakManagerHook initInstance(Bot bot) {
        instance = new BreakManagerHook(bot);
        return instance;
    }


    private BreakManagerHook(Bot IiIiiiIiiII) {
        super(IiIiiiIiiII);
    }

    @Override
    public synchronized boolean shouldActivate() {
        if(breakEarly && !shouldActivateCalled) {
            log(String.format("Thread %d notifying...", Thread.currentThread().getId()));
            shouldActivateCalled = true;
            this.notify();
        }

        if(super.shouldActivate() && breakEarly) {
            breakEarly = false;
            log("breakEarly -> false");
        }
        return super.shouldActivate() || breakEarly;
    }

    @Override
    public void onExit() {
        super.onExit();
        log("Return from break!");
    }

    public synchronized void startBreakEarly() throws InterruptedException {
        breakEarly = true;
        shouldActivateCalled = false;
        while (!shouldActivateCalled) {
            log(String.format("Thread %d waiting until shouldActivate() called...", Thread.currentThread().getId()));
            this.wait();
        }
        log("Exited startBreakEarly");
    }
}

Edited by yfoo

On 9/8/2024 at 4:11 PM, yfoo said:

This was the end result I settled with. I also happened to need a hook to know when the break ended to potentially check if my position was crashed while I was away. The OnExit() allows me to know that. For now I'm not doing anything with it just logging (log("Return from break!");)
 

public class BreakManagerHook extends BreakManager {

This looks like it will work? have you tested it yet?

  • Author
On 9/14/2024 at 9:49 PM, dubai said:

This looks like it will work? have you tested it yet?

When I wrote it like 2 weeks ago it worked. 
You need to override the break manager with an instance of the class

Put this in onStart

bot.getRandomExecutor().overrideOSBotRandom(BreakManagerHook.initInstance(bot));

Then use this to start a break early. 

BreakManagerHook.getInstance().startBreakEarly();

 

Edited by yfoo

On 9/17/2024 at 9:44 AM, yfoo said:

When I wrote it like 2 weeks ago it worked. 
You need to override the break manager with an instance of the class

Put this in onStart

bot.getRandomExecutor().overrideOSBotRandom(BreakManagerHook.initInstance(bot));

Then use this to start a break early. 

BreakManagerHook.getInstance().startBreakEarly();

 

Hope you don't mind if I just copy and paste this :D :D

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.