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.

Listener

Featured Replies

I already created my own listener, it just people were telling me to put it in a thread, which make sences. And have the thread loop it's self.

So far I have created the thread started it once. And that's it -.-

How did you create a listener if it wasn't a thread?

  • Author

How did you create a listener if it wasn't a thread?

well i created a test script and had a method from the listener class loop within the onloop. But since it was a test and there wasnt anything else in the onloop. It was fine. But once i add it into my crafter, i noticed it will excute the listener, then execute the actual on loop. Which wasnt what i wanted. Then i started reading about threads, and i didnt know that when a thread starts it will execute the Run method in the class that implement runnable. Which i had So im guessing this is where i will need the loop, people were telling me about.

 

edit: i guess not lol -.-

Edited by josedpay

package _test;

import java.util.Arrays;

import org.osbot.rs07.api.model.Item;
import org.osbot.rs07.api.util.ItemContainer;

public class ContainerListener implements Runnable {
	
	private final ItemContainer container;
	private Item[] cache;
	private boolean changed;
	
	public ContainerListener(ItemContainer container) {
	this.container = container;
	}
	
	public void setCache() {
		cache = container.getItems();
		changed = false;
	}
	
	@Override
	public void run() {
		changed = Arrays.equals(cache, container.getItems());
		try {
			Thread.sleep(1200);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
	public boolean getChanged() {
		return changed;
	}

}
ContainerListener inventoryListener = new ContainerListener(getInventory());

This most likely won't work as it is, but might inspire you or something ^^

  • Author
package _test;

import java.util.Arrays;

import org.osbot.rs07.api.model.Item;
import org.osbot.rs07.api.util.ItemContainer;

public class ContainerListener implements Runnable {
	
	private final ItemContainer container;
	private Item[] cache;
	private boolean changed;
	
	public ContainerListener(ItemContainer container) {
	this.container = container;
	}
	
	public void setCache() {
		cache = container.getItems();
		changed = false;
	}
	
	@Override
	public void run() {
		changed = Arrays.equals(cache, container.getItems());
		try {
			Thread.sleep(1200);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
	public boolean getChanged() {
		return changed;
	}

}
ContainerListener inventoryListener = new ContainerListener(getInventory());

This most likely won't work as it is, but might inspire you or something ^^

 

shouldnt the run method contain a loop?

Guest
This topic is now closed to further replies.

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.