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.

Creating wrapper?

Featured Replies

I'm creating wrapper classes for some stuff, however it seems that for this one at least I'm getting an NPE when I check for whether it exists or not. Here's the (unfinished) wrapper class:

package core.utils.wrappers;

import org.osbot.accessor.XGroundItem;
import org.osbot.script.Script;
import org.osbot.script.rs2.model.GroundItem;

/**
 * Created with IntelliJ IDEA
 * User: Anthony
 * Date: 5/13/2014
 */

public class Loot extends GroundItem {

	private XGroundItem instance;
	private Script sI;

	public Loot(XGroundItem instance, Script sI) {
		super(instance);
		this.instance = instance;
		this.sI = sI;
	}

	public void pickUp(boolean loopUntilPickedUp) throws InterruptedException {
		do {
			interact("Take");
		}
		while (loopUntilPickedUp && exists());
	}

	public XGroundItem getInstance() {
		return instance;
	}

}

The part where I am getting the NPE is when I declare an object of type Loot and call the #exists() method (could be an issue for other methods but I haven't got past this one yet). I declare the object in a similar fashion to this:

Loot loot = new Loot(closestGroundItemForName("whatever").instance, sI);

The error message is then logged to the console:

[ERROR][05/14/14 08:10:52 AM]: Error on executing script worker!
java.lang.NullPointerException
	at org.osbot.script.rs2.model.GroundItem.getZ(zf:147)
	at org.osbot.script.rs2.map.Region.contains(dg:154)
	at org.osbot.script.rs2.model.GroundItem.exists(zf:84)
	at core.tasks.Looter.execute(Looter.java:41)
	at core.task_framework.TaskManager.findAndExecuteTaskInCategory(TaskManager.java:22)
	at core.Main.onLoop(Main.java:133)
	at org.osbot.hc.run(um:136)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

Any help would be appreciated. I feel like I'm doing something incredibly stupid O_o

 

 

FYI my other wrapper classes work fine.

Edited by Swizzbeat

I'm creating wrapper classes for some stuff, however it seems that for this one at least I'm getting an NPE when I check for whether it exists or not. Here's the (unfinished) wrapper class:

package core.utils.wrappers;

import org.osbot.accessor.XGroundItem;
import org.osbot.script.Script;
import org.osbot.script.rs2.model.GroundItem;

/**
 * Created with IntelliJ IDEA
 * User: Anthony
 * Date: 5/13/2014
 */

public class Loot extends GroundItem {

	private XGroundItem instance;
	private Script sI;

	public Loot(XGroundItem instance, Script sI) {
		super(instance);
		this.instance = instance;
		this.sI = sI;
	}

	public void pickUp(boolean loopUntilPickedUp) throws InterruptedException {
		do {
			interact("Take");
		}
		while (loopUntilPickedUp && exists());
	}

	public XGroundItem getInstance() {
		return instance;
	}

}

The part where I am getting the NPE is when I declare an object of type Loot and call the #exists() method (could be an issue for other methods but I haven't got past this one yet). I declare the object in a similar fashion to this:

Loot loot = new Loot(closestGroundItemForName("whatever").instance, sI);

The error message is then logged to the console:

[ERROR][05/14/14 08:10:52 AM]: Error on executing script worker!
java.lang.NullPointerException
	at org.osbot.script.rs2.model.GroundItem.getZ(zf:147)
	at org.osbot.script.rs2.map.Region.contains(dg:154)
	at org.osbot.script.rs2.model.GroundItem.exists(zf:84)
	at core.tasks.Looter.execute(Looter.java:41)
	at core.task_framework.TaskManager.findAndExecuteTaskInCategory(TaskManager.java:22)
	at core.Main.onLoop(Main.java:133)
	at org.osbot.hc.run(um:136)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

Any help would be appreciated. I feel like I'm doing something incredibly stupid O_o

 

 

FYI my other wrapper classes work fine.

 

Silly Swizz <3 you can't call interact like that (interact("Take")), because that would try to call the interact method inherited from GroundItem, which will try to use some instance variables inherited from GroundItem, which are null because you never set them up (for example the position of the item).

 

Try casting instance and then calling interact on that... ((GroundItem)instance).interact("Take");

Edited by ericthecmh

  • Author

Silly Swizz <3 you can't call interact like that (interact("Take")), because that would try to call the interact method inherited from GroundItem, which will try to use some instance variables inherited from GroundItem, which are null because you never set them up (for example the position of the item).

Try casting instance and then calling interact on that... ((GroundItem)instance).interact("Take");

But I do, hence the super call passing the instance :p
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.