Empyrean GB 7 Posted September 13, 2019 Hello everyone, I've been trying to work with an Item filter. if I use the setup it works for the Bank.depositAllExcept(Filter<Item> filter) method. However when I try to apply it on an actual Item taken from my Inventory I can't get it to work. I've tried tweaking around with it in a small AbstractScript that generates an output. The script is as following: private Filter<Item> itemWithID(Integer... ids){ for(int i: ids){ log("" + i); } List<Integer> test = Arrays.asList(ids); for(int i: test){ log("" + i); } return new Filter<Item>(){ List<Integer> items = Arrays.asList(ids); @Override public boolean match(Item i) { log("in match"); for(int in: items){ log("item with id " + in); } return items.contains(i.getID()); } }; } @Override public int onLoop() { Filter filter = itemWithID(303, 323, 666); List<org.dreambot.api.wrappers.items.Item> itemsToDeposit = Game.getInstance().get().getInventory().getCollection(); for(org.dreambot.api.wrappers.items.Item i:itemsToDeposit){ log("Checking item: " + i.getName() + " with id: " + i.getID()); if(filter.equals(i)){ log("filter was true"); }else{ log("filter was false"); } } this.stop(); return 5000; } When running it it generates the following output: 303 323 666 303 323 666 Checking item: Raw anchovies with id: 321 filter was false Checking item: Small fishing net with id: 303 filter was false Checking item: Anchovies with id: 319 filter was false Checking item: Raw shrimps with id: 317 filter was false Checking item: Burnt fish with id: 323 filter was false How do I use the filter in a way that will get in the right branch of the if statement for the small fishing net and burnt fish? EmpyreanGB
Empyrean GB 7 Author Posted September 13, 2019 Thank you @falloutr how much of an idiot I actually am. The solution is simply to actually call the match method and not the equals method. A object ofcourse will never be the reference to the filter.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.