Class NodeRegistry

java.lang.Object
com.soulfiremc.server.script.nodes.NodeRegistry

public final class NodeRegistry extends Object
Registry of all available script node types. Metadata is stored separately from node instances — nodes are pure executors.
  • Method Details

    • register

      public static void register(NodeMetadata metadata, Supplier<ScriptNode> factory)
      Registers a node type with its metadata and factory. Metadata is stored separately — no node instance is created during registration.
      Parameters:
      metadata - the node metadata (provides type identifier, ports, etc.)
      factory - the factory to create node instances on demand
    • create

      public static ScriptNode create(String type)
      Gets a cached instance of a node by its type. Node instances are stateless, so the same instance can be safely reused.
      Parameters:
      type - the node type identifier
      Returns:
      the cached node instance
      Throws:
      IllegalArgumentException - if the type is not registered
    • getMetadata

      public static NodeMetadata getMetadata(String type)
      Gets the metadata for a registered node type.
      Parameters:
      type - the node type identifier
      Returns:
      the node metadata
      Throws:
      IllegalArgumentException - if the type is not registered
    • computeDefaultInputs

      public static Map<String, NodeValue> computeDefaultInputs(NodeMetadata metadata)
      Computes default input values from node metadata port definitions.
      Parameters:
      metadata - the node metadata
      Returns:
      a map of input names to their default values
    • isRegistered

      public static boolean isRegistered(String type)
      Checks if a node type is registered.
      Parameters:
      type - the node type identifier
      Returns:
      true if the type is registered
    • getRegisteredTypes

      public static Set<String> getRegisteredTypes()
      Gets all registered node types.
      Returns:
      set of all registered type identifiers
    • getRegisteredCount

      public static int getRegisteredCount()
      Gets the number of registered node types.
      Returns:
      the count of registered types
    • getAllMetadata

      public static List<NodeMetadata> getAllMetadata()
      Gets metadata for all registered node types.
      Returns:
      list of all node metadata
    • getFilteredMetadata

      public static List<NodeMetadata> getFilteredMetadata(String categoryId, boolean includeDeprecated)
      Gets metadata for all registered node types, optionally filtered.
      Parameters:
      categoryId - optional category ID filter (null for all)
      includeDeprecated - whether to include deprecated nodes
      Returns:
      list of matching node metadata
    • getAllCategories

      public static List<NodeCategory> getAllCategories()
      Gets all categories sorted by sort order.
      Returns:
      sorted list of all NodeCategory values