Class TargetSpec

java.lang.Object
privbot.mechanics.TargetSpec

public final class TargetSpec extends Object
Which NPCs count as a target: by name, by id, minus an ignore list, optionally inside an area. Immutable; each builder call returns a new spec.

What it proves: matches(privbot.mechanics.NpcView) is true when the NPC's id is listed or its name matches, it is not ignored by name, and (if an area is set) its tile is inside the area. A name entry starting with = is an exact match; any other entry matches when either string contains the other. With contains(false) every entry is an exact match. Comparison is case-insensitive and trims spaces. With no names and no ids nothing matches, except for any(), which matches every NPC (still minus the ignore list, and only inside the area if one is set).

Unreadable looks like: a null name never matches by name, and a null tile fails an area check. It never matches by guess.

Thread rule: pure, safe on any thread.

  • Method Details

    • any

      public static TargetSpec any()
      A spec matching every NPC; narrow it with ignore(java.lang.String...) or within(net.runelite.api.coords.WorldArea).
    • named

      public static TargetSpec named(String... names)
      A spec matching these names. A plain entry matches by containment in BOTH directions (the name-matching rule): "spectre" matches "Aberrant spectre", and "aberrant spectre" also matches an NPC named just "Spectre". Prefix an entry with = for an exact match, or call contains(false) to make every entry exact.
    • ids

      public static TargetSpec ids(int... ids)
      A spec matching these NPC ids, whatever their name.
    • alsoIds

      public TargetSpec alsoIds(int... ids)
      Also matches these NPC ids, whatever their name (adds ids to a spec built with named(java.lang.String...)).
    • ignore

      public TargetSpec ignore(String... names)
      Never matches an NPC whose name matches one of these (same rules as names).
    • within

      public TargetSpec within(net.runelite.api.coords.WorldArea area)
      Only matches NPCs whose tile is inside area.
    • contains

      public TargetSpec contains(boolean contains)
      true (default): plain entries match by containment; false: every entry is an exact match.
    • matches

      public boolean matches(NpcView npc)