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.

The public type Sleep must be defined in its own file

Featured Replies

I'm still new to this so instead of using conditional sleeps all the time I decided to do this code at the top of my file.

public final class Sleep extends ConditionalSleep {

 

private final BooleanSupplier condition;

 

public Sleep(final BooleanSupplier condition, final int timeout) {

super(timeout);

this.condition = condition;

}

 

public Sleep(final BooleanSupplier condition, final int timeout, final int interval) {

super(timeout, interval);

this.condition = condition;

}

 

@Override

public final boolean condition() throws InterruptedException {

return condition.getAsBoolean();

}

 

public static boolean sleepUntil(final BooleanSupplier condition, final int timeout) {

return new Sleep(condition, timeout).sleep();

}

 

public static boolean sleepUntil(final BooleanSupplier condition, final int timeout, final int interval) {

return new Sleep(condition, timeout, interval).sleep();

}

}

I get this error in eclipse The public type Sleep must be defined in its own file.

 

I try and run this code and get this error in the log when running.

 

if(inventory.contains(Items))

{

if(!myPlayer().isAnimating() || !myPlayer().isMoving()) {

inventory.getItem("Knife").interact("Use");

sleep(random(400,2000));

inventory.getItem(Items).interact("use");

Sleep.sleepUntil(() -> !inventory.contains(Items) || getDialogues().clickContinue() || myPlayer().isMoving(), 15000);

log("can I continue to cook or no?");

continuecooking = 1;

log("Continuein to cook activated.");

}

}

 

The error in the console when running shows

[ERROR][Bot #1][02/12 01:57:38 PM]: Error in bot executor or from Error class (and not Exception)!
java.lang.Error: Unresolved compilation problem:

 at core.Sleep.sleepUntil(Main.java:43)
 at core.Main.onLoop(Main.java:204)
 at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(ji:48)
 at java.lang.Thread.run(Unknown Source)

 

Java doesn't support two public classes in a single .java file. You'll need to put the declaration in a separate .java file.

 

I must ask, this looks a lot more convoluted than just using conditional sleeps, what about them do you not like?

On 2/12/2019 at 7:33 PM, luciuspragg said:

Java doesn't support two public classes in a single .java file. You'll need to put the declaration in a separate .java file.

 

I must ask, this looks a lot more convoluted than just using conditional sleeps, what about them do you not like?

It appears to be using BooleanSupplier which is mostly syntax sugar. That way, instead of doing:

new ConditionalSleep(1000) {
		
		@Override
		public boolean condition() throws InterruptedException {
			return myPlayer().isUnderAttack();
		}
		
	}.sleep();

His Sleep class wraps it up and reduces it down to just:

new Sleep(myPlayer()::isUnderAttack, 1000).sleep();

Or similarly if you call the static methods in the Sleep class.

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.