Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

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

Author of MaxiBots
Joined
Dec 3, 2013
Messages
7,032
Seems to always return true.
Code:
    Filter<SpriteItem> axeFilter = new Filter<SpriteItem>() {

        @Override
        public boolean accepts(SpriteItem item) {
            // TODO Auto-generated method stub
            return item != null && item.getDefinition() != null && item.getDefinition().getName().toLowerCase().contains("axe") && !item.getDefinition().getName().toLowerCase().contains("broken");
        }

    };
No matter what i change the name to, containsAllOf(filter) returns true.
 
Joined
Jul 24, 2014
Messages
188
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).
 
Author of MaxiBots
Joined
Dec 3, 2013
Messages
7,032
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).
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.
 
Joined
Jul 24, 2014
Messages
188
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.
I see.. as a temporary workaround use multiple containsAnyOf() ?
Cloud will probably be able to fix this :p
 
Author of MaxiBots
Joined
Dec 3, 2013
Messages
7,032
I see.. as a temporary workaround use multiple containsAnyOf() ?
Cloud will probably be able to fix this :p
Only need one, and i am :) It's just to see if we have a usable axe, if we don't then the script stops.
 
Engineer
Joined
Jul 28, 2013
Messages
2,776
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.
 
Author of MaxiBots
Joined
Dec 3, 2013
Messages
7,032
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.
Ahh yes that destinction should probably be made in the docs or something lol
 
Top