Jump to content

NPE on getting an object


Khaleesi

Recommended Posts

Mirror client version:

mirror 2.1 with osbot 2.4.83

 

Console output / terminal output:

Code used:

RS2Object object = script.getObjects().closest("Altar");

Error:

[ERROR][Bot #1][08/05 09:30:04 PM]: Error in script executor!
java.lang.NullPointerException
at org.osbot.rs07.api.Objects.getAll(ki:126)
at org.osbot.rs07.api.EntityAPI.closest(fp:32)
at org.osbot.rs07.api.EntityAPI.closest(fp:156)
at org.osbot.rs07.api.EntityAPI.closest(fp:117)
at org.khal.runecrafterv2.a.NuL.D(n:90)
at org.khal.runecrafterv2.e.a.nUL.k(w:42)
at org.khal.runecrafterv2.e.a.nUL.G(w:202)
at org.khal.runecrafterv2.KhalRunecrafter.onLoop(db:210)
at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(vi:149)
at java.lang.Thread.run(Unknown Source)

Crash report if a crash occurred:

/

 

Script that you ran:

Khal AIO Runecrafter 

 

Hooks that failed:

None

 

JVM/Browser bit version (32 / 64):

java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b15, mixed mode)
Link to comment
Share on other sites

I can confirm this issue similarly as well. In order to consistently NOT get NPE I null check the name, and definition using stream.

 

So something like: 

objects.getAll().stream().filter(w -> w.getDefinition() != null && w.getDefinition().getName() != null)

Then you can obviously add something to the effect of

w.getDefinition.getName().equalsIgnoreCase("your filter")

From there you can use .sorted() and a good lamda expression to sort by distance however you may like. 

 

Hope that helps.

Link to comment
Share on other sites

I can confirm this issue similarly as well. In order to consistently NOT get NPE I null check the name, and definition using stream.

 

So something like: 

objects.getAll().stream().filter(w -> w.getDefinition() != null && w.getDefinition().getName() != null)

Then you can obviously add something to the effect of

w.getDefinition.getName().equalsIgnoreCase("your filter")

From there you can use .sorted() and a good lamda expression to sort by distance however you may like. 

 

Hope that helps.

 

I tried that but didn't work.

Throws an error while trying to get all object. (org.osbot.rs07.api.Objects.getAll())

I'm guessing the mirror returns a null Objects object. Will be investigating this.

Link to comment
Share on other sites

Do you have any delay when entering the alter before getting objects? Maybe it's trying to get objects before they have loaded into the client. 

 

I would imagine that part of the validate statement saying whether or not we are ready to execute involves making sure the character is within a certain area which means the area and objects should have loaded. 

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Do you have any delay when entering the alter before getting objects? Maybe it's trying to get objects before they have loaded into the client. 

 

I would imagine that part of the validate statement saying whether or not we are ready to execute involves making sure the character is within a certain area which means the area and objects should have loaded. 

 

Ya it doesn't matter unfortunately ... :/

Tried get all the way to the root of the problem, but will still get the same thing over and over.

 

Nobody can tell me the exact issue unfortunately

Link to comment
Share on other sites

  • 3 weeks later...
  • 3 weeks later...
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...