Class Equipment

java.lang.Object
privbot.hooks.Equipment

public final class Equipment extends Object
Worn equipment: ctx.equipment. Reads go through the plugin's adapter, which knows where each server keeps the worn items (on some servers that is not the RuneLite item container), so they answer on every server.

Prefer snapshot() for decisions: one immutable read per tick. query() re-reads on every call. Writes (unequip(java.lang.String...)) return dispatch acceptance; verify the slot emptied.

  • Method Details

    • snapshot

      public ItemContainerSnapshot snapshot()
      Immutable worn-slot facts; see Inventory.snapshot() for source and read-scope rules.
    • query

      public ItemQuery query()
      A fresh query over the worn items (one read per call).
      Returns:
      the query
    • contains

      public boolean contains(int... ids)
      Parameters:
      ids - item ids
      Returns:
      whether any worn item has one of ids
    • contains

      public boolean contains(String... names)
      Parameters:
      names - item names (matched as ItemQuery.withName(java.lang.String...) does)
      Returns:
      whether any worn item matches one of names
    • count

      public int count(int id)
      Parameters:
      id - an item id
      Returns:
      the total quantity worn with that id (ammunition stacks count their quantity)
    • get

      public PrivItem get(Predicate<PrivItem> pred)
      Parameters:
      pred - the test
      Returns:
      the first worn item that matches, or null
    • first

      public PrivItem first(Predicate<PrivItem> pred)
      Parameters:
      pred - the test
      Returns:
      the first worn item that matches, or null
    • isEmpty

      public boolean isEmpty()
      Returns:
      whether nothing is worn (also true when the worn container could not be read: use snapshot() to tell the two apart)
    • unequip

      public boolean unequip(String... names)
      Removes the first worn item matching names with its "Remove" action, sent the way this server's own Remove click is sent.
      Parameters:
      names - item names
      Returns:
      dispatch acceptance; false when nothing worn matches
    • interact

      public boolean interact(int itemId, String action)
      Interact with a worn item without moving it into inventory. On a server where PrivBot does not know how to send action on a worn item, this refuses (returns false) rather than sending an inventory action, which would not address the equipped item.
    • find

      public static PrivItem find(Predicate<PrivItem> pred)
      Static lookup that needs no ctx; prefer ctx.equipment.get(pred).
      Parameters:
      pred - the test
      Returns:
      the first worn item that matches, or null