Search in sources :

Example 6 with Query

use of net.runelite.api.Query in project runelite by runelite.

the class BindNeckOverlay method getNecklaceWidgetItems.

private Collection<WidgetItem> getNecklaceWidgetItems() {
    Query inventoryQuery = new InventoryWidgetItemQuery().idEquals(BINDING_NECKLACE);
    WidgetItem[] inventoryWidgetItems = queryRunner.runQuery(inventoryQuery);
    Query equipmentQuery = new EquipmentItemQuery().slotEquals(WidgetInfo.EQUIPMENT_AMULET).idEquals(BINDING_NECKLACE);
    WidgetItem[] equipmentWidgetItems = queryRunner.runQuery(equipmentQuery);
    Collection<WidgetItem> necklaces = new ArrayList<>();
    necklaces.addAll(Arrays.asList(inventoryWidgetItems));
    necklaces.addAll(Arrays.asList(equipmentWidgetItems));
    return necklaces;
}
Also used : InventoryWidgetItemQuery(net.runelite.api.queries.InventoryWidgetItemQuery) EquipmentItemQuery(net.runelite.api.queries.EquipmentItemQuery) Query(net.runelite.api.Query) EquipmentItemQuery(net.runelite.api.queries.EquipmentItemQuery) InventoryWidgetItemQuery(net.runelite.api.queries.InventoryWidgetItemQuery) ArrayList(java.util.ArrayList) WidgetItem(net.runelite.api.widgets.WidgetItem)

Example 7 with Query

use of net.runelite.api.Query in project runelite by runelite.

the class JewelleryCountOverlay method getJewelleryWidgetItems.

private Collection<WidgetItem> getJewelleryWidgetItems() {
    Query inventoryQuery = new InventoryWidgetItemQuery();
    WidgetItem[] inventoryWidgetItems = queryRunner.runQuery(inventoryQuery);
    Query equipmentQuery = new EquipmentItemQuery().slotEquals(WidgetInfo.EQUIPMENT_AMULET, WidgetInfo.EQUIPMENT_RING, WidgetInfo.EQUIPMENT_GLOVES, WidgetInfo.EQUIPMENT_WEAPON);
    WidgetItem[] equipmentWidgetItems = queryRunner.runQuery(equipmentQuery);
    Collection<WidgetItem> jewellery = new ArrayList<>();
    jewellery.addAll(Arrays.asList(inventoryWidgetItems));
    jewellery.addAll(Arrays.asList(equipmentWidgetItems));
    return jewellery;
}
Also used : InventoryWidgetItemQuery(net.runelite.api.queries.InventoryWidgetItemQuery) EquipmentItemQuery(net.runelite.api.queries.EquipmentItemQuery) Query(net.runelite.api.Query) EquipmentItemQuery(net.runelite.api.queries.EquipmentItemQuery) InventoryWidgetItemQuery(net.runelite.api.queries.InventoryWidgetItemQuery) ArrayList(java.util.ArrayList) WidgetItem(net.runelite.api.widgets.WidgetItem)

Example 8 with Query

use of net.runelite.api.Query in project runelite by runelite.

the class ClueScrollPlugin method checkForClues.

@Schedule(period = 600, unit = ChronoUnit.MILLIS)
public void checkForClues() {
    if (client.getGameState() == GameState.LOGIN_SCREEN) {
        clue = null;
        return;
    }
    npcsToMark = null;
    objectsToMark = null;
    equippedItems = null;
    if (clue instanceof NpcClueScroll) {
        String npc = ((NpcClueScroll) clue).getNpc();
        if (npc != null) {
            Query query = new NPCQuery().nameContains(npc);
            npcsToMark = queryRunner.runQuery(query);
        }
    }
    if (clue instanceof ObjectClueScroll) {
        int objectId = ((ObjectClueScroll) clue).getObjectId();
        if (objectId != -1) {
            GameObjectQuery query = new GameObjectQuery().idEquals(objectId);
            objectsToMark = queryRunner.runQuery(query);
        }
    }
    if (clue instanceof EmoteClue) {
        equippedItems = new HashSet<>();
        Item[] result = queryRunner.runQuery(new InventoryItemQuery(InventoryID.EQUIPMENT));
        if (result != null) {
            for (Item item : result) {
                equippedItems.add(item.getId());
            }
        }
    }
    ClueScroll clue = findClueScroll();
    if (clue == null && this.clue != null) {
        // wait for WAIT_DURATION before discarding the knowledge of the player having a clue.
        if (Instant.now().compareTo(clueTimeout.plus(WAIT_DURATION)) < 0) {
            return;
        }
    }
    // so the clue window doesn't have to be open.
    if (clue != null) {
        this.clue = clue;
        this.clueTimeout = Instant.now();
    }
}
Also used : InventoryItemQuery(net.runelite.api.queries.InventoryItemQuery) NPCQuery(net.runelite.api.queries.NPCQuery) Query(net.runelite.api.Query) GameObjectQuery(net.runelite.api.queries.GameObjectQuery) TextClueScroll(net.runelite.client.plugins.cluescrolls.clues.TextClueScroll) ClueScroll(net.runelite.client.plugins.cluescrolls.clues.ClueScroll) NpcClueScroll(net.runelite.client.plugins.cluescrolls.clues.NpcClueScroll) ObjectClueScroll(net.runelite.client.plugins.cluescrolls.clues.ObjectClueScroll) NPCQuery(net.runelite.api.queries.NPCQuery) InventoryItemQuery(net.runelite.api.queries.InventoryItemQuery) WorldPoint(net.runelite.api.coords.WorldPoint) NpcClueScroll(net.runelite.client.plugins.cluescrolls.clues.NpcClueScroll) Item(net.runelite.api.Item) EmoteClue(net.runelite.client.plugins.cluescrolls.clues.EmoteClue) ObjectClueScroll(net.runelite.client.plugins.cluescrolls.clues.ObjectClueScroll) GameObjectQuery(net.runelite.api.queries.GameObjectQuery) Schedule(net.runelite.client.task.Schedule)

Example 9 with Query

use of net.runelite.api.Query in project runelite by runelite.

the class FightCavePlugin method findJad.

private NPC findJad() {
    Query query = new NPCQuery().nameContains("TzTok-Jad");
    NPC[] result = queryRunner.runQuery(query);
    return result.length >= 1 ? result[0] : null;
}
Also used : NPC(net.runelite.api.NPC) Query(net.runelite.api.Query) NPCQuery(net.runelite.api.queries.NPCQuery) NPCQuery(net.runelite.api.queries.NPCQuery)

Aggregations

Query (net.runelite.api.Query)9 InventoryWidgetItemQuery (net.runelite.api.queries.InventoryWidgetItemQuery)6 WidgetItem (net.runelite.api.widgets.WidgetItem)6 EquipmentItemQuery (net.runelite.api.queries.EquipmentItemQuery)3 NPCQuery (net.runelite.api.queries.NPCQuery)3 Point (java.awt.Point)2 Rectangle (java.awt.Rectangle)2 ArrayList (java.util.ArrayList)2 NPC (net.runelite.api.NPC)2 Varbits (net.runelite.api.Varbits)2 BufferedImage (java.awt.image.BufferedImage)1 Item (net.runelite.api.Item)1 Point (net.runelite.api.Point)1 WorldPoint (net.runelite.api.coords.WorldPoint)1 GameObjectQuery (net.runelite.api.queries.GameObjectQuery)1 InventoryItemQuery (net.runelite.api.queries.InventoryItemQuery)1 ClueScroll (net.runelite.client.plugins.cluescrolls.clues.ClueScroll)1 EmoteClue (net.runelite.client.plugins.cluescrolls.clues.EmoteClue)1 NpcClueScroll (net.runelite.client.plugins.cluescrolls.clues.NpcClueScroll)1 ObjectClueScroll (net.runelite.client.plugins.cluescrolls.clues.ObjectClueScroll)1