stevenl4 0 Share Posted January 11, 2017 Using Java8 say I wanted to deposit everything except a Bronze pickaxe, I'd use getBank().depositAllExcept(items -> items.getName().equals("Bronze pickaxe")); What do I do if I want to deposit everything except a Bronze pickaxe, 500 coins and Varrock teleport tab using similar code? Link to comment Share on other sites More sharing options...
Pandemic 2675 Share Posted January 11, 2017 Using Java8 say I wanted to deposit everything except a Bronze pickaxe, I'd use getBank().depositAllExcept(items -> items.getName().equals("Bronze pickaxe")); What do I do if I want to deposit everything except a Bronze pickaxe, 500 coins and Varrock teleport tab using similar code? If it's just a couple things, you can do: getBank().depositAllExcept(i -> i.getName().equals("Bronze pickaxe") || i.getName().equals("Coins")); Otherwise you can have a list of names, and do: getBank().depositAllExcept(i -> list.contains(i.getName())); Link to comment Share on other sites More sharing options...
stevenl4 0 Author Share Posted January 11, 2017 If it's just a couple things, you can do: getBank().depositAllExcept(i -> i.getName().equals("Bronze pickaxe") || i.getName().equals("Coins")); Otherwise you can have a list of names, and do: getBank().depositAllExcept(i -> list.contains(i.getName())); I think the second one is what I'm looking for, how do I create a list of items currently in my inventory at the beginning of the script? Thanks Link to comment Share on other sites More sharing options...
Neffarion 485 Share Posted January 11, 2017 I think the second one is what I'm looking for, how do I create a list of items currently in my inventory at the beginning of the script? Thanks ArrayList<Item> invItems = new ArrayList<>(getInventory().all()); That will work but you need to call that when you need to check. If you just call at the beginning of the script it will only get the items that exist in the inventory at the beginning of the script Link to comment Share on other sites More sharing options...
Eclipseop 194 Share Posted January 12, 2017 ArrayList<Item> invItems = new ArrayList<>(getInventory().all()); That will work but you need to call that when you need to check. If you just call at the beginning of the script it will only get the items that exist in the inventory at the beginning of the script Why construct it as an arraylist when #all returns a list? unless there is some reason why you need an arraylist over a list xd Link to comment Share on other sites More sharing options...
Neffarion 485 Share Posted January 12, 2017 Why construct it as an arraylist when #all returns a list? unless there is some reason why you need an arraylist over a list xd ArrayList rules! Just got used to do it tbh Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.