/** * Gets the equipped item at the given index from the last known array of items. * * @param slot the <code>Slot</code> of the item * @return an <code>Item</code>; otherwise <code>null</code> if invalid */ public static Item getCachedItem(final Slot slot) { final Widget cache = Widgets.get(WIDGET); if (cache != null && cache.validate()) { try { return new Item(cache.getChild(slot.getComponentIndex())); } catch (ArrayIndexOutOfBoundsException ignored) { } } return null; }
/** * Gets the equipped item at the given index. * * @param slot the <code>Slot</code> of the item * @return an <code>Item</code>; otherwise <code>null</code> if invalid */ public static Item getItem(final Slot slot) { final Widget widget = getWidget(); if (widget != null && widget.validate()) { try { final WidgetChild itemComp = (widget.getIndex() == WIDGET_BANK) ? widget.getChild(COMPONENT_EQUIP_INVENTORY).getChild(slot.getBankComponentIndex()) : widget.getChild(slot.getComponentIndex()); if (itemComp != null) { return new Item(itemComp); } } catch (IndexOutOfBoundsException ignored) { } } return null; }