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.

[2.4.133] Override break manager issue

Featured Replies

1. OSBot Version (do NOT put "current version", be specific)

2.4.133

2. A description of the issue. Include relevant logs.

If a script that overrides the break manager is started while logged out, shouldActivate may throw an error. This (for some reason) causes the auto login random (and maybe others) to stop triggering.

The error occurs because of an NPE thrown if shouldActivate tries to access client.getLoginState(). Which in most cases will be required.

3. Are you receiving any errors in the client canvas or the logger?

NPE

4. How can you replicate the issue?

1. While logged out, run a script that overrides the break manager (and accesses loginState in shouldActivate)
2. Autologin stops triggering

	@Override
	public void onStart() throws InterruptedException {
		bot.getRandomExecutor().overrideOSBotRandom(new BreakManager(bot));
	}

	@Override
	public int onLoop() throws InterruptedException {
		return 1000;
	}

5. Has this issue persisted through multiple versions? If so, how far back?

First noticed in 2.4.133

Edited by FrostBug

bot.getRandomExecutor().overrideOSBotRandom(new RandomSolver(RandomEvent.BREAK_MANAGER) {
    @Override
    public boolean shouldActivate() {
        return false;
    }

    @Override
    public int onLoop() throws InterruptedException {
        return 0;
    }
});

 

I think since you're trying to initialize the BreakManager class you're going to get some strange errors, the above code is what you should be using. Also note that the script does NOT execute at all until you are fully logged into the game.

  • Author
12 minutes ago, Alek said:

bot.getRandomExecutor().overrideOSBotRandom(new RandomSolver(RandomEvent.BREAK_MANAGER) {
    @Override
    public boolean shouldActivate() {

        return false;
    }

    @Override
    public int onLoop() throws InterruptedException {
        return 0;
    }
});

I think since you're trying to initialize the BreakManager class you're going to get some strange errors, the above code is what you should be using. Also note that the script does NOT execute at all until you are fully logged into the game.

This will also trigger the issue:

bot.getRandomExecutor().overrideOSBotRandom(new RandomSolver(RandomEvent.BREAK_MANAGER) {
    @Override
    public boolean shouldActivate() {
	return getClient().getLoginState() == LoginState.LOGGED_IN;
    }

    @Override
    public int onLoop() throws InterruptedException {
        return 0;
    }
});

The problem with using a BreakManager instance is that the default break manager makes the very same check on client LoginState as above

Edited by FrostBug

  • Author

Easy way to reproduce @Alek:

1. Compile this script

	@Override
	public void onStart() throws InterruptedException {
		bot.getRandomExecutor().overrideOSBotRandom(new RandomSolver(RandomEvent.BREAK_MANAGER) {
			@Override
			public boolean shouldActivate() {
				log(getClient().getLoginState());
				return false;
			}

			@Override
			public int onLoop() throws InterruptedException {
				return 0;
			}
		});
	}

	@Override
	public int onLoop() throws InterruptedException {
		return 5000;
	}

2. Enable breaks in client settings

3. Start the script while logged out

4. Once logged in thru autologin/welcomescreen solvers; wait 10 seconds

5. Manually log out while the script is still running - Autologin will not trigger

Edited by FrostBug

Looks like a context issue. Try this inner class:

 

class CustomBreakManager extends RandomSolver {
    private Bot _bot;
    CustomBreakManager(Bot bot) {
        super(RandomEvent.BREAK_MANAGER);
        _bot = bot;
    }

    @Override
    public boolean shouldActivate() {
        _bot.getLogger().info(".");
        return false;
    }

    @Override
    public int onLoop() throws InterruptedException {
        return 0;
    }

}


@Override
public void onStart() {
    bot.getRandomExecutor().overrideOSBotRandom(new CustomBreakManager(bot));
}
  • Author
On 2017/8/21 at 3:52 PM, Alek said:

Looks like a context issue. Try this inner class:

 


class CustomBreakManager extends RandomSolver {
    private Bot _bot;
    CustomBreakManager(Bot bot) {
        super(RandomEvent.BREAK_MANAGER);
        _bot = bot;
    }

    @Override
    public boolean shouldActivate() {
        _bot.getLogger().info(".");
        return false;
    }

    @Override
    public int onLoop() throws InterruptedException {
        return 0;
    }

}


@Override
public void onStart() {
    bot.getRandomExecutor().overrideOSBotRandom(new CustomBreakManager(bot));
}

So.. Just creating a new class, subclassing BreakManager, seems to have solved the 'context issue' to some extent.
Tho it seems that you always must override the getName method; otherwise it fails anyway.

Another still scary thing is that any exception thrown from the overridden break manager seems to permanently disable all random solvers

EDIT: But it works now :boge: thanks

Edited by FrostBug

  • Alek locked this topic
Guest
This topic is now closed to further replies.

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.