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


    distraction
     Share

    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.

    Edited by distraction
    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.

    That makes sense, thank you for the help.

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     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.