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

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

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

  1. Aidden

    Aidden Author of MaxiBots

    Joined:
    Dec 3, 2013
    Messages:
    6,600
    Likes Received:
    990
    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,938
    Likes Received:
    1,266
  3. Exile

    Joined:
    Jul 24, 2014
    Messages:
    188
    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 Author of MaxiBots

    Joined:
    Dec 3, 2013
    Messages:
    6,600
    Likes Received:
    990
    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:
    188
    Likes Received:
    23
    I see.. as a temporary workaround use multiple containsAnyOf() ?
    Cloud will probably be able to fix this :p
     
  6. Aidden

    Aidden Author of MaxiBots

    Joined:
    Dec 3, 2013
    Messages:
    6,600
    Likes Received:
    990
    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 Engineer

    Joined:
    Jul 28, 2013
    Messages:
    2,777
    Likes Received:
    1,124
    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 Author of MaxiBots

    Joined:
    Dec 3, 2013
    Messages:
    6,600
    Likes Received:
    990
    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,938
    Likes Received:
    1,266
    Agreed @Cloud.
     
  10. Cloud

    Cloud Engineer

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

Share This Page

Loading...