1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

HintArrows.getLoaded().get(0) gives me an NPE

Discussion in 'Developer Support' started by Fontkodo, Feb 11, 2015.

  1. Fontkodo

    Joined:
    Jun 21, 2014
    Messages:
    350
    Likes Received:
    111
    Here is the code I'm trying to use to get the falcon specific to the local player, however it always gives me an NPE. I get a java.lang.arrayindexoutofboundsexception error when it tries to run.
    Code (Text):
    1. if (HintArrows.getLoaded() != null) {
    2.  
    3.                     HintArrow caught = HintArrows.getLoaded().get(0);
    4.                  
    5.                     if (caught != null) {
    6.                         Npc caughtBird = Npcs.getLoadedAt(caught.getPosition()).first();
    7.                         clickThing(caughtBird, "Retrieve");
    8.                  
    9.                 }
    10.      }
    The HintArrow definitely is not null and from what I understand, 0 should be the very first loaded HintArrow, so what is causing the error?

    Edit: Mostly fixed, I'm just having problems with interacting with the falcon...
     
    #1 Fontkodo, Feb 11, 2015
    Last edited: Feb 11, 2015
  2. SlashnHax

    Joined:
    Dec 10, 2014
    Messages:
    3,198
    Likes Received:
    1,041
    If it's an ArrayIndexOutOfBoundsException then the query results are empty.
     
  3. Fontkodo

    Joined:
    Jun 21, 2014
    Messages:
    350
    Likes Received:
    111
    Aidden pointed this out on skype and I just made sure to check that the list wasn't empty and I was able to mostly solve my problem. I had trouble with clicking the falcon though, the results weren't empty but the script bot would be stuck trying to interact but wouldn't. For now I've just made falcon retrieval only activate when the HintArrow doesn't return an empty list and then just relied on clicking the closest falcon, which should prevent clicking other people's falcons in a majority of cases.
     
  4. SlashnHax

    Joined:
    Dec 10, 2014
    Messages:
    3,198
    Likes Received:
    1,041
    What's the NPE you said you were getting btw?
     

Share This Page

Loading...