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.

Null pointer Exception when executing a webwalkevent

Featured Replies

Here is a walk function I made, the error occurs on the execute(walkEvent) line.

public void walk(Area area) throws InterruptedException{
        WebWalkEvent walkEvent = new WebWalkEvent(area);
        execute(walkEvent);
        while (!area.contains(myPlayer().getPosition())) {
            Thread.sleep(1000);
        }
    }

 

This is called like this: walk(new Area(3189, 3273, 3189, 3272));

 

Does anyone know what is wrong with this function that would be causing it to throw a null pointer exception?

 

 

 

 

Not sure why it would be throwing an NPE, usually this happens when someone calls the wrong execute function, which you are not.

Bit of a tip as well, that while loop is going to do nothing as it wont start until the webwalk event has finished.

 

Could you paste the entire exception? 

Edited by Tom

  • Author
1 hour ago, Tom said:

Not sure why it would be throwing an NPE, usually this happens when someone calls the wrong execute function, which you are not.

Bit of a tip as well, that while loop is going to do nothing as it wont start until the webwalk event has finished.

 

Could you paste the entire exception? 

The reason I have that loop there was for testing purposes because in a previous iteration I had a web walk event that led into a NPC interaction and the bot would try to interact with the NPC as it was walking before it got to the actual area and opened the door before the npc

  • Author
58 minutes ago, Malcolm said:

This probably could throw an NPE if you have this in a separate class and don’t extend method provider in that class and exchange context. Although this should be pretty obvious as your IDE should highlight that for you as an error 

You don’t need to remove the parameter. You’d just call it like you have. Alternatively you could make a variable for your area and call walk(variable); 

My walk function is in a separate class that does extend the Method Provider. 

1 hour ago, Tom said:

Not sure why it would be throwing an NPE, usually this happens when someone calls the wrong execute function, which you are not.

Bit of a tip as well, that while loop is going to do nothing as it wont start until the webwalk event has finished.

 

Could you paste the entire exception? 

image.png.425aa01084c62df12f7b82704e106de6.png

Osbot crashes as this is running so I can not copy paste, However here is a screenshot.

1 hour ago, redgar72 said:

My walk function is in a separate class that does extend the Method Provider. 

image.png.425aa01084c62df12f7b82704e106de6.png

Osbot crashes as this is running so I can not copy paste, However here is a screenshot.

Can you provide a copy of all of your script or at least up to where the error is occurring (line 62). You can pm me if you don't want to share it publicly.

Also, I'm not sure why you included the sleep part. If a WebWalk event fails, you might as well just have it log out rather than constantly sleeping till it logs out anyways. There's definitely a better way to do whatever you are trying to do, but I would need to see the context. You can also check if a webWalk event is able to be completed before you even start walking. 

 public boolean canWalk(Area area) {
        WebWalkEvent w = new WebWalkEvent(area);
        return w.prefetchRequirements(this);
    }

This will return true if a destination is found and directions are created. In which case, there's really no reason it wouldn't reach the destination.

8 hours ago, redgar72 said:

My walk function is in a separate class that does extend the Method Provider. 

image.png.425aa01084c62df12f7b82704e106de6.png

Osbot crashes as this is running so I can not copy paste, However here is a screenshot.

If its in a different class, you need to either exchange context, or not extend method provider and use dependency injection instead, like so

void walk(Script instance, Area area){

    WebWalkEvent e = new WebWalkEvent(area);
    instance.execute(e);
 

}

  • Author
11 hours ago, Tom said:

If its in a different class, you need to either exchange context, or not extend method provider and use dependency injection instead, like so

void walk(Script instance, Area area){

    WebWalkEvent e = new WebWalkEvent(area);
    instance.execute(e);
 

}

I merged the two classes and I am still getting a NPE at the same line

1 hour ago, redgar72 said:

I merged the two classes and I am still getting a NPE at the same line

Gonna need to see all your code, PM me if you like

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.