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.

[OSBOT 2] Inventory Listening

Featured Replies

Since the API doesn't have inventory listening as of July 14th, 2014, I created my own.

package com.tyluur.utility.listener;
 
import org.osbot.rs07.api.model.Item;
 
/**
 * @author Tyluur <itstyluur@gmail.com>
 * @since Jul 9, 2014
 */
public interface InventoryItemListener {
 
public void handle(Item item);
}
package com.tyluur.utility.listener;
 
import java.util.ArrayList;
import java.util.List;
 
import org.osbot.rs07.api.model.Item;
import org.osbot.rs07.script.Script;
 
/**
 * @author Tyluur <itstyluur@gmail.com>
 * @since Jul 9, 2014
 */
@SuppressWarnings("deprecation")
public class InventoryListener {
 
public InventoryListener(Script script) {
this.script = script;
updateItems();
}
 
/**
* The main tick event
*/
public void process(InventoryItemListener event) {
List<Item> ourItems = currentInventory;
List<Item> newItems = getNewInventory();
for (int i = 0; i < ourItems.size(); i++) {
Item ourItem = ourItems.get(i);
Item newItem = newItems.get(i);
if (ourItem.getId() != newItem.getId() || ourItem.getAmount() != newItem.getAmount()) {
event.handle(newItem);
}
}
updateItems();
}
 
private List<Item> getNewInventory() {
List<Item> newList = new ArrayList<>(28);
for (int i = 0; i < script.inventory.getItems().length; i++) {
Item item = script.inventory.getItems()[i];
if (item == null)
item = new Item(-1, -1);
newList.add(item);
}
return newList;
}
 
/**
* Updates our inventory item list with all the items in our inventory, and
* clearing the list first of all contents
*/
private void updateItems() {
currentInventory.clear();
 
if (script.inventory != null && script.inventory.getItems() != null)
for (int i = 0; i < script.inventory.getItems().length; i++) {
Item item = script.inventory.getItems()[i];
if (item == null)
item = new Item(-1, -1);
currentInventory.add(item);
}
}
 
/**
* The script this being ran on
*/
private final Script script;
 
/**
* The list of the items in our inventory, updated every time the
* {@link #process()} method is called
*/
private final List<Item> currentInventory = new ArrayList<>(28);
 
}

Edited by Tyluur

  • Author

make it run on another thread bitch!

This is just a snippet, do whatever you want with it bitch!

This is just a snippet, do whatever you want with it bitch!

 

bitch i was trying to help i guess you don't love pelicans no more..

If you do put it on a separate thread make sure you keep in mind the potential for race conditions

  • 2 weeks later...

If you do put it on a separate thread make sure you keep in mind the potential for race conditions

this.

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.