A couple things:
Remove the random "sleep(50)" you have when right clicking an item as the menu opens on mouse press and not release. You can create a RectangleDestination to move your mouse to in one line instead of creating two different variables like you're doing, just pass a RectangleDestination the bounds of the slot you need (aka a Rectangle). moveMouse returns a boolean for a reason. Return the value returned by the method to see if it really did complete successfully. Arrays.asList is a great method to use for things like this. Just use the get(0) method to see if the action you want is the first one instead of iterating through them. Instead of an enhanced for loop just increment until your value is equal to the array size, then break because the action would not have been found.
I wrote this a few days ago for a friend. Haven't tested it out but it should be beneficial if you don't understand my points
public boolean interactInventoryItem(String itemName, String interaction) throws InterruptedException {
Item[] items = client.getInventory().getItems();
if (items == null)
return false;
RectangleDestination itemDestination = new RectangleDestination(new Rectangle(client.getInventory().getDestinationForSlot(client.getInventory().getSlotForName(itemName)).getBounds()));
for (Item currentItem : items) {
if (currentItem.getName().equalsIgnoreCase(itemName)) {
String[] itemActions = currentItem.getDefinition().getActions();
if (itemActions[0].equalsIgnoreCase(interaction))
return client.moveMouseTo(itemDestination, false, true, false);
else {
for (int i = 1; i < itemActions.length; i++) {
if (itemActions[i].equalsIgnoreCase(interaction)) {
client.moveMouseTo(itemDestination, false, true, true);
if (client.isMenuOpen()) {
List<Option> options = client.getMenu();
for (int j = 0; j < options.size(); j++) {
if (options.get(i).action.equalsIgnoreCase(interaction)) {
return client.moveMouseTo(new RectangleDestination(client.getMenuX(), client.getMenuY()+21+i*14, client.getMenuWidth(), 10), false, true, false);
}
}
}
}
}
}
}
}
return false;
}