Ejemplo n.º 1
0
 /**
  * Gets all the equipped items.
  *
  * @return an array instance of <code>Item</code>
  */
 public static Item[] getItems() {
   final Widget widget = getWidget();
   if (widget != null) {
     final boolean isBank = widget.getIndex() != WIDGET;
     final WidgetChild[] equip =
         (isBank)
             ? widget.getChild(COMPONENT_EQUIP_INVENTORY).getChildren()
             : widget.getChildren();
     if (equip.length > 0) {
       if (!isBank) {
         final Item[] items = new Item[NUM_SLOTS];
         final Slot[] slots = Slot.values();
         for (int i = 0; i < NUM_SLOTS; i++) {
           items[i] = new Item(equip[slots[i].getComponentIndex()]);
         }
         return items;
       } else {
         final Item[] items = new Item[equip.length];
         for (int i = 0; i < items.length; i++) {
           items[i] = new Item(equip[i]);
         }
         return items;
       }
     }
   }
   return new Item[0];
 }
Ejemplo n.º 2
0
 public static WidgetChild getTab(final MainTabs tab) {
   final Record record = get();
   update(record);
   if (record.index_widget == -1) {
     return null;
   }
   final Widget widget = Widgets.get(record.index_widget);
   if (widget != null) {
     final int index = tab.getIndex();
     if (index < 0 || index > 16) {
       return null;
     }
     if (record.indices_tabs[index] == -1) {
       for (final WidgetChild widgetChild : widget.getChildren()) {
         final String[] actions = widgetChild.getActions();
         if (actions != null
             && actions.length > 0
             && actions[0].equalsIgnoreCase(tab.getDescription())) {
           record.indices_tabs[index] = widgetChild.getIndex();
           break;
         }
       }
     }
     if (record.indices_tabs[index] != -1) {
       return Widgets.get(record.index_widget, record.indices_tabs[index]);
     }
   }
   return null;
 }
Ejemplo n.º 3
0
 /**
  * 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;
 }
Ejemplo n.º 4
0
 /**
  * Gets all the equipped items. If the tab is not currently open, it will not open it and will
  * return the last known array of items.
  *
  * @return an array instance of <code>Item</code>
  */
 public static Item[] getCachedItems() {
   final Widget widget = Widgets.get(WIDGET);
   if (widget != null) {
     final WidgetChild[] components = widget.getChildren();
     if (components.length > 0) {
       final Item[] items = new Item[NUM_SLOTS];
       final Slot[] slots = Slot.values();
       for (int i = 0; i < NUM_SLOTS; i++) {
         items[i] = new Item(components[slots[i].getComponentIndex()]);
       }
       return items;
     }
   }
   return new Item[0];
 }
Ejemplo n.º 5
0
 /**
  * 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;
 }
Ejemplo n.º 6
0
 public static WidgetChild getMap() {
   final Record record = get();
   update(record);
   if (record.index_widget == -1) {
     return null;
   }
   final Widget widget = Widgets.get(record.index_widget);
   if (widget != null) {
     if (record.index_map == -1) {
       for (final WidgetChild widgetChild : widget.getChildren()) {
         if (widgetChild.getSpecialType() == 1338) {
           record.index_map = widgetChild.getIndex();
           break;
         }
       }
     }
     if (record.index_map != -1) {
       return Widgets.get(record.index_widget, record.index_map);
     }
   }
   return null;
 }
Ejemplo n.º 7
0
 public static WidgetChild getCompass() {
   final Record record = get();
   update(record);
   if (record.index_widget == -1) {
     return null;
   }
   final Widget widget = Widgets.get(record.index_widget);
   if (widget != null) {
     if (record.index_compass == -1) {
       for (final WidgetChild widgetChild : widget.getChildren()) {
         final String[] actions = widgetChild.getActions();
         if (actions != null && actions.length == 1 && actions[0].equalsIgnoreCase("Face North")) {
           record.index_compass = widgetChild.getIndex();
           break;
         }
       }
     }
     if (record.index_compass != -1) {
       return Widgets.get(record.index_widget, record.index_compass);
     }
   }
   return null;
 }