Resolved Inventory.containsAllOf(Filter<SpriteItem>) is broken

Discussion in 'Client & Site Support' started by Aidden, Aug 5, 2014.

  1. Aidden

    Aidden The better executive ;)

    Joined:
    Dec 3, 2013
    Messages:
    3,295
    Likes Received:
    665
    Seems to always return true.
    Code (Text):
    1.  
    2.     Filter<SpriteItem> axeFilter = new Filter<SpriteItem>() {
    3.  
    4.         @Override
    5.         public boolean accepts(SpriteItem item) {
    6.             // TODO Auto-generated method stub
    7.             return item != null && item.getDefinition() != null && item.getDefinition().getName().toLowerCase().contains("axe") && !item.getDefinition().getName().toLowerCase().contains("broken");
    8.         }
    9.  
    10.     };
    11.  
    No matter what i change the name to, containsAllOf(filter) returns true.
     
  2. Arbiter

    Arbiter Mod Automation

    Joined:
    Jul 26, 2013
    Messages:
    2,522
    Likes Received:
    1,039
  3. Exile

    Joined:
    Jul 24, 2014
    Messages:
    189
    Likes Received:
    23
    Try (just a suggestion):

    Suggestion 1:

    item.getDefinition().getName().toString().toLowerCase().contains("axe")

    Suggestion 2:
    Do a System.out.println(); on every single of the 4 conditions in your return statement and check which one is returning true when it shouldn't(play a bit with it to find out the wrong one).
     
  4. Aidden

    Aidden The better executive ;)

    Joined:
    Dec 3, 2013
    Messages:
    3,295
    Likes Received:
    665
    The thing is, when i change it to Inventory.containsAnyOf(filter) using the same filter, it works correctly. So i'm assuming it's not a problem with the filter.
     
  5. Exile

    Joined:
    Jul 24, 2014
    Messages:
    189
    Likes Received:
    23
    I see.. as a temporary workaround use multiple containsAnyOf() ?
    Cloud will probably be able to fix this :p
     
  6. Aidden

    Aidden The better executive ;)

    Joined:
    Dec 3, 2013
    Messages:
    3,295
    Likes Received:
    665
    Only need one, and i am :) It's just to see if we have a usable axe, if we don't then the script bot stops.
     
  7. Cloud

    Cloud The Developer

    Joined:
    Jul 28, 2013
    Messages:
    2,332
    Likes Received:
    758
    The naming for this particular overload may be bad. Whereas the containsAllOf(String/int) verify that each individual element is in there, containsAllOf(Filter) does a check to verify that all of the items in the inventory match the given filter.
     
    Exile likes this.
  8. Aidden

    Aidden The better executive ;)

    Joined:
    Dec 3, 2013
    Messages:
    3,295
    Likes Received:
    665
    Ahh yes that destinction should probably be made in the docs or something lol
     
  9. Arbiter

    Arbiter Mod Automation

    Joined:
    Jul 26, 2013
    Messages:
    2,522
    Likes Received:
    1,039
    Agreed @Cloud.
     
  10. Cloud

    Cloud The Developer

    Joined:
    Jul 28, 2013
    Messages:
    2,332
    Likes Received:
    758
    It was renamed as soon as it got brought up.
     
    Exile likes this.

Share This Page

Loading...