Class BehaviorRegistry

java.lang.Object
net.citizensnpcs.api.ai.tree.BehaviorRegistry
Direct Known Subclasses:
CitizensBehaviorRegistry

public class BehaviorRegistry extends Object
Registry for behavior factories that can be instantiated from DataKey configurations.
  • Constructor Details

  • Method Details

    • createBehavior

      public Behavior createBehavior(String name, DataKey params, BehaviorRegistry.BehaviorContext context)
      Creates a behavior instance from the registry.
      Parameters:
      name - the behavior name
      params - the DataKey containing parameters
      context - the creation context
      Returns:
      the created behavior, or null if not found
    • getExpressionRegistry

      public ExpressionRegistry getExpressionRegistry()
    • getSignalManager

      public SignalManager getSignalManager()
    • hasBehavior

      public boolean hasBehavior(String name)
      Checks if a behavior is registered.
      Parameters:
      name - the behavior name
      Returns:
      true if registered
    • parseDuration

      protected int parseDuration(String durationStr, ExpressionScope scope)
      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

      public void registerBehavior(String name, BehaviorRegistry.BehaviorFactory factory)
      Registers a behavior factory.
      Parameters:
      name - the behavior name
      factory - the factory to create behavior instances
    • registerDefaults

      protected void registerDefaults()
      Registers default built-in behaviors.