Package net.citizensnpcs.api.ai.tree
Class BehaviorRegistry
java.lang.Object
net.citizensnpcs.api.ai.tree.BehaviorRegistry
- Direct Known Subclasses:
CitizensBehaviorRegistry
Registry for behavior factories that can be instantiated from
DataKey configurations.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classContext passed to behavior factories during creation.static interface -
Constructor Summary
ConstructorsConstructorDescriptionBehaviorRegistry(ExpressionRegistry expressions) BehaviorRegistry(ExpressionRegistry expressionRegistry, SignalManager signals) -
Method Summary
Modifier and TypeMethodDescriptioncreateBehavior(String name, DataKey params, BehaviorRegistry.BehaviorContext context) Creates a behavior instance from the registry.booleanhasBehavior(String name) Checks if a behavior is registered.protected intparseDuration(String durationStr, ExpressionScope scope) Helper to parse duration with time unit support (e.g., "5s", "10m", "100t").voidregisterBehavior(String name, BehaviorRegistry.BehaviorFactory factory) Registers a behavior factory.protected voidRegisters default built-in behaviors.
-
Constructor Details
-
BehaviorRegistry
public BehaviorRegistry() -
BehaviorRegistry
-
BehaviorRegistry
-
-
Method Details
-
createBehavior
public Behavior createBehavior(String name, DataKey params, BehaviorRegistry.BehaviorContext context) Creates a behavior instance from the registry.- Parameters:
name- the behavior nameparams- the DataKey containing parameterscontext- the creation context- Returns:
- the created behavior, or null if not found
-
getExpressionRegistry
-
getSignalManager
-
hasBehavior
Checks if a behavior is registered.- Parameters:
name- the behavior name- Returns:
- true if registered
-
parseDuration
Helper to parse duration with time unit support (e.g., "5s", "10m", "100t"). Falls back to expression evaluation if not a valid duration string. -
registerBehavior
Registers a behavior factory.- Parameters:
name- the behavior namefactory- the factory to create behavior instances
-
registerDefaults
protected void registerDefaults()Registers default built-in behaviors.
-