xVril 28 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 28 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 965 Share Posted May 22, 2020 getInventory().get(n-> n !=null && n.getName().contains("Games necklace(") Link to comment Share on other sites More sharing options...
Pseudo 179 Share Posted May 22, 2020 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); } } } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.