Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • Interacting with Agility potions causes exception. It definitely isn't my code..


    You win
     Share

    Recommended Posts

    Here is the section of my code which will throw the error

     

    Item potion = getInventory().get(i -> i.getName().contains("potion") );

     

    if(potion != null){

     

    potion.interact("Drink");

     

    log("potion drank, squeeze time!");

     

     

     

    i've tried contains(Aility)

    i have also tried the ID of the object (all 4 )

     

    Yeah...

    Edited by You win
    Link to comment
    Share on other sites

    You need to make sure the filter filters out everything that is null before it tries to get names like this

     

    Item potion = getInventory().get(i -> i != null && i.getName().contains("potion") );

    Edited by rokaHakor
    Link to comment
    Share on other sites

     

    You need to make sure the filter filters out everything that is null before it tries to get names like this

     

    Item potion = getInventory().get(i -> i != null && i.getName().contains("potion") );

     

     

    god dam it.. trying ti out now..

     

    You need to make sure the filter filters out everything that is null before it tries to get names like this

     

    Item potion = getInventory().get(i -> i != null && i.getName().contains("potion") );

     

    yep... fml

    Link to comment
    Share on other sites

    He's technically right, it's not his code. Its due to the filter method not skipping null objects, which to me... makes zero sense on why it would attempt to check properties on a null object.

    Link to comment
    Share on other sites

    He's technically right, it's not his code. Its due to the filter method not skipping null objects, which to me... makes zero sense on why it would attempt to check properties on a null object.

     

    Actually that is true.

    Link to comment
    Share on other sites

     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.