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
  • getBank().count(string) / getBank().contains(string) and placeholders


    distraction

    Recommended Posts

    I recently noticed that "getBank().count(string)" will return "1" for some (maybe all?) items with placeholders, even if there aren't actually any of that item left in the bank. I ended up coming across this while debugging to figure out why "getBank().contains(string)" was returning true when there wasn't any of the item left in the bank. I checked what "getBank().count(string)" returned if there actually was one of the item in the bank, and that also returns "1". I also checked what it returns if there are more than one of the item in the bank, and that seemed to work as expected. Releasing the placeholder seems to fix the issue, so the issue (if it is in fact a bug) seems to be to do with placeholders.

     

    Is this a bug? If not, what would be the proper way to check if there are none of the item left in the bank with placeholders on? For now I have resorted to checking if the amount left is 1 or less.

     

    The items that I confirmed this happening for were "Flax", and "Iron ore". It may happen for other/all items, but I only tested for those two.

    Link to comment
    Share on other sites

     

    I recently noticed that "getBank().count(string)" will return "1" for some (maybe all?) items with placeholders, even if there aren't actually any of that item left in the bank. I ended up coming across this while debugging to figure out why "getBank().contains(string)" was returning true when there wasn't any of the item left in the bank. I checked what "getBank().count(string)" returned if there actually was one of the item in the bank, and that also returns "1". I also checked what it returns if there are more than one of the item in the bank, and that seemed to work as expected. Releasing the placeholder seems to fix the issue, so the issue (if it is in fact a bug) seems to be to do with placeholders.
     
    Is this a bug? If not, what would be the proper way to check if there are none of the item left in the bank with placeholders on? For now I have resorted to checking if the amount left is 1 or less.
     
    The items that I confirmed this happening for were "Flax", and "Iron ore". It may happen for other/all items, but I only test for those two.

     

    You can use widgets to check if it's a placeholder, maybe there's a better solution idk.

    Link to comment
    Share on other sites

    It's because the placeholder is still an item in the bank.

    If you want it to not include placeholders, then you can do count(i->i != null && i.getName().equals("name"); && !i.isPlaceholder()) or something along those line.

    Link to comment
    Share on other sites

    It's because the placeholder is still an item in the bank.

    If you want it to not include placeholders, then you can do count(i->i != null && i.getName().equals("name"); && !i.isPlaceholder()) or something along those line.

    That makes sense, thank you for the help.

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • 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.