Jump to content
minewarriors

Nullpointer Exception using Worlds

Recommended Posts

Hello y'all,

I just started making my first private script and it is close to finished however worldhopping is not working for me for some reason.

Worlds worldhop = new Worlds();
store.close();
if(worldhop!=null) {
    worldhop.getWorlds().hopToF2PWorld();
    this.x = x - x;
}

This is the code and I get this in the logger:

[ERROR][Bot #1][07/01 08:30:41 PM]: Error in script executor!
java.lang.NullPointerException at Main.onLoop(Main.java:51)
at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(kl:223)
at java.lang.Thread.run(Unknown Source)

line 51 is worldhop.getWorlds().hopToF2PWorld();

The problem has nothing to do with store.close(); I already tested this.

Does anybody have a clue why I get this error? If I fix this my first script is finally done ?

Thanks in advance for all the help!

Link to comment
Share on other sites

9 minutes ago, Night said:

You're not calling the world hopping correctly. If you're in your main class you can do getWorlds().hopToF2PWorld();
The reason you're getting an NPE is it's looking for your script instance for context, when you're creating your own Worlds object it doesn't have this context.

So I have te remove the declaration and initialisation of worlds? let me try.

11 minutes ago, Night said:

You're not calling the world hopping correctly. If you're in your main class you can do getWorlds().hopToF2PWorld();
The reason you're getting an NPE is it's looking for your script instance for context, when you're creating your own Worlds object it doesn't have this context.

ow damn it worked!!!! thank you so much!!! <3

  • Like 1
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...