Class Npcs
java.lang.Object
com.botwithus.bot.api.entities.Npcs
NPC query facade. Singleton per
GameAPI; obtain via
api.npcs().
Holds a definition cache so repeat
getNpcType lookups for
the same typeId are free after the first hit. NpcType is
effectively immutable per session, so cache entries never expire — the
map only grows, bounded in practice by the number of distinct NPC types
a script encounters (typically < 100).
Npc target = api.npcs().query()
.named("Goblin")
.withinDistance(15)
.filter(n -> n.hasOption("Attack"))
.nearest();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classQuery subclass — wires the snapshot stream + name resolution toEntityQuery. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionall(int typeId) All NPCs of the given type id.All NPCs whose name matchesname(case-insensitive contains).allByGameval(String gameval) All NPCs with the given gameval name.voidDrop the definition cache.intDiagnostic — current size of the NpcType cache.nearest(int typeId) Nearest NPC of the given type id, ornull.Nearest NPC matchingname(case-insensitive contains), ornull.nearestByGameval(String gameval) Nearest NPC with the given gameval name (e.g.query()Start a fluent query.
-
Constructor Details
-
Npcs
-
-
Method Details
-
query
Start a fluent query. Each call returns a fresh builder. -
nearest
-
nearest
Nearest NPC of the given type id, ornull. -
all
-
all
-
nearestByGameval
Nearest NPC with the given gameval name (e.g."HANS"), ornull. Distinct fromnearest(String), which matches the localised display name. -
allByGameval
All NPCs with the given gameval name. Distinct fromall(String), which matches the localised display name. -
clearDefinitionCache
public void clearDefinitionCache()Drop the definition cache. Useful after a game update or for tests. -
definitionCacheSize
public int definitionCacheSize()Diagnostic — current size of the NpcType cache.
-