Class Parent<C>
java.lang.Object
privbot.task.SimpleNode<C>
privbot.task.Parent<C>
- Type Parameters:
C- context type shared across the task tree
- All Implemented Interfaces:
TaskNode<C>
Shared parent node that owns a local group of
Child tasks and selects
the highest-priority eligible child when it executes.
Plugin authors interact with this class by:
- Subclassing it for a parent concern such as recovery, combat, or loot
- Adding child tasks via
addChild(Child) - Optionally overriding
shouldExecuteParent(Object)for a parent-level gate
SimpleNode, so it works naturally
with TaskNodeRunner and other existing task APIs.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a child to this group, normally from the subclass constructor.voidcleanup()CallsTaskNode.cleanup()on every child.final booleanExecutes the child remembered byshouldExecute(C)(or selects one again when called without it) and returns that child's result.The child chosen by the lastexecute(C), or null when none ran or after a reset.final StringThe name ofgetActiveChild(), or null.An unmodifiable view of the registered children, in registration order.The active child's status, or this node's own status when no child is active.voidreset()Clears the active and remembered child and resets every child.final booleanshouldExecute(C ctx) True whenshouldExecuteParent(C)passes and at least one enabled child validates.protected booleanshouldExecuteParent(C ctx) Group-level gate, checked before any child.Methods inherited from class privbot.task.SimpleNode
addStatusListener, getLastExecutionTime, getName, getPriority, getTimeSinceLastExecution, handleError, isComplete, isEnabled, markExecuted, removeStatusListener, setEnabled, status, toString
-
Constructor Details
-
Parent
- Parameters:
name- human-readable name for logging and overlay displaypriority- this group's priority among the runner's top-level nodes (higher wins)
-
Parent
Creates a parent with priority0.
-
-
Method Details
-
addChild
Adds a child to this group, normally from the subclass constructor. Children with equal priority keep this registration order.- Returns:
- this parent, for chaining
- Throws:
IllegalArgumentException- ifchildis null
-
getChildren
-
getActiveChild
The child chosen by the lastexecute(C), or null when none ran or after a reset. -
getActiveChildName
The name ofgetActiveChild(), or null. -
shouldExecuteParent
Group-level gate, checked before any child. Return false to skip the whole group this tick (no child predicate runs). Same rules asTaskNode.shouldExecute(C): read-only, no dispatch, no waits. Defaults to true. -
shouldExecute
True whenshouldExecuteParent(C)passes and at least one enabled child validates. Remembers the highest-priority eligible child for the followingexecute(C)call. A child whose predicate throws is skipped and passed to itshandleError.- Parameters:
ctx- the shared context containing state and dependencies- Returns:
- true if the task should execute, false otherwise
-
execute
Executes the child remembered byshouldExecute(C)(or selects one again when called without it) and returns that child's result. Only one child runs per call. A child that throws goes to itshandleErrorand the call returns false.- Parameters:
ctx- the shared context- Returns:
- true if the task performed an action (blocks sibling tasks from executing this tick), false otherwise
-
getStatus
The active child's status, or this node's own status when no child is active.- Specified by:
getStatusin interfaceTaskNode<C>- Overrides:
getStatusin classSimpleNode<C>- Parameters:
ctx- the shared context- Returns:
- a brief status description. Defaults to
TaskNode.getName().
-
reset
-
cleanup
public void cleanup()CallsTaskNode.cleanup()on every child.
-