Item[] contents = inventory.getItems();
if (contents.length > 0) {
if (inventory.interact("Interact with this shiz", contents[contents.length - 1].toString()));
}
Something like this i would assume. i have not tested it or anything but you could try it and tell me how it goes! :P