Class ScriptGraph
java.lang.Object
com.soulfiremc.server.script.ScriptGraph
Represents the graph structure of a visual script.
Contains nodes and edges that define the execution flow and data connections.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder for constructing ScriptGraph instances.static enumType of edge connection.static final recordRepresents an edge connecting two nodes.static final recordRepresents a node in the graph.static enumSeverity levels for validation diagnostics.static final recordA structured validation diagnostic with node/edge context and severity. -
Method Summary
Modifier and TypeMethodDescriptionstatic ScriptGraph.BuilderCreates a new builder for constructing a ScriptGraph.Returns all DATA edges in the graph for diagnostic purposes.edges()Finds all trigger nodes (entry points) in the graph.getIncomingDataEdges(String nodeId) Gets all incoming DATA edges for a node.getNextExecutionNodes(String nodeId, String outputHandle) Gets the next execution nodes from a given node's output handle.@Nullable ScriptGraph.GraphNodeGets a node by its ID.booleanhasIncomingExecutionEdges(String nodeId) Returns whether a node has any incoming execution edges.nodes()scriptId()Performs topological sort on the graph nodes.warnings()
-
Method Details
-
builder
Creates a new builder for constructing a ScriptGraph. -
dataEdges
Returns all DATA edges in the graph for diagnostic purposes. -
getNode
Gets a node by its ID.- Parameters:
nodeId- the node identifier- Returns:
- the node, or null if not found
-
findTriggerNodes
-
hasIncomingExecutionEdges
Returns whether a node has any incoming execution edges. Nodes without incoming execution edges that are not triggers will not be executed by the engine unless explicitly triggered.- Parameters:
nodeId- the node identifier- Returns:
- true if the node has at least one incoming execution edge
-
getNextExecutionNodes
-
getIncomingDataEdges
Gets all incoming DATA edges for a node. Uses pre-computed map for O(1) lookup instead of scanning all edges.- Parameters:
nodeId- the target node ID- Returns:
- list of DATA edges targeting this node
-
topologicalSort
Performs topological sort on the graph nodes. Returns nodes in execution order, respecting dependencies.- Returns:
- list of node IDs in topological order
- Throws:
IllegalStateException- if the graph contains cycles
-
scriptId
-
scriptName
-
nodes
-
edges
-
outgoingEdgesByHandle
-
incomingEdgesByHandle
-
incomingDataEdgesByNode
-
nodesWithIncomingExecution
-
warnings
-