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

[Snippet] Event Decorators: time out & break condition decorations

Featured Replies

Example:

// Event will break after 10 seconds.
execute(EventDecorator.withTimeout(new WalkingEvent(leArea), 10)); 

// Event will break when player is animating (a bit random but ok..)
execute(EventDecorator.withBreakCondition(new InteractionEvent(goblin, "Attack"), () -> myPlayer().isAnimating())); 

Code:

package org.botre.osbot.event;

import java.util.function.BooleanSupplier;

import org.dreamstream.moka.main.time.FetchingTimer;
import org.dreamstream.moka.main.time.Timer;
import org.osbot.rs07.event.Event;

public final class EventDecorator {

	private EventDecorator() {
	
	}
	
	public static final Event withBreakCondition(Event event, BooleanSupplier breakCondition) {
		return new Event() {
			@Override
			public void onStart() {
				try {
					super.onStart();
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				event.setAsync();
				execute(event);
			}
			@Override
			public int execute() throws InterruptedException {
				boolean failed = breakCondition.getAsBoolean();
				if(failed) {
					event.setFailed();
					setFailed();
				}
				return 100;
			}
			@Override
			public boolean hasFailed() {
				boolean failed = breakCondition.getAsBoolean();
				if(failed) {
					event.setFailed();
					setFailed();
				}
				return failed || event.hasFailed();
			}
			@Override
			public boolean hasFinished() {
				return event.hasFinished();
			}
		};
	}
	
	public static final Event withTimeout(Event event, int timeoutSeconds) throws IllegalArgumentException {
		if(timeoutSeconds < 0) throw new IllegalArgumentException();
		Timer timer = FetchingTimer.milliseconds();
		return withBreakCondition(event, () -> {
			return timer.getElapsedSeconds() > timeoutSeconds;	
		});
	}
	
}

Edited by Botre

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

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.