xVril 12 Share Posted May 22, 2020 A Games necklace can have various charges meaning its Integer ID and String name change. I have tried to handle the various IDs/ names the Item can have by using a Filter as follows: if (s.getInventory().contains(Filters.GAMES_NECKLACE_FILTER)) { if (s.getInventory().interact(Filters.GAMES_NECKLACE_FILTER, "Rub")) { MethodProvider.sleep(1000, 2000); s.getKeyboard().type("1", false); return true; It is able to verify that the Inventory contains a Games necklace but it is unable to interact with it. Any solutions? public static final Filter<Item> GAMES_NECKLACE_FILTER = item -> item.getName().contains("Games necklace"); Link to comment Share on other sites More sharing options...
xVril 12 Author Share Posted May 22, 2020 Solution is the below, was thinking there might be an easier way to do it. if (s.getInventory().contains(Filters.GAMES_NECKLACE_FILTER)) { for(Item i : s.getInventory().all()) if(i != null && Filters.GAMES_NECKLACE_FILTER.match(i)) { s.getInventory().interact(i.getName(), "Rub"); MethodProvider.sleep(1000, 2000); s.getKeyboard().type("1", false); return true; } Link to comment Share on other sites More sharing options...
Zawy 795 Share Posted May 22, 2020 (edited) getInventory().get(n-> n !=null && n.getName().contains("Games necklace(") Edited May 22, 2020 by Zawy xVril 1 Link to comment Share on other sites More sharing options...
Pseudo 178 Share Posted May 22, 2020 (edited) Nice job on finding a solution, but you shouldn't have to iterate over the whole inventory. Something such as the following ought to work to suit: Item gamesNecklace = getInventory().get(i -> i.getName().contains("Games necklace(")); if (gamesNecklace != null) { if (teleportOptionsDialog != null) { //pseudo code teleportOptionsDialog.interact("string"); sleepUntil(() -> !teleportOptionsDialog.isVisible(), 3000); } else { if (gamesNecklace.interact("Rub")) { sleepUntil(() -> teleportOptionsDialog != null, 3000); } } } Edited May 22, 2020 by Pseudo xVril 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now