Class AbstractScriptNode

java.lang.Object
com.soulfiremc.server.script.AbstractScriptNode
All Implemented Interfaces:
ScriptNode
Direct Known Subclasses:
AbsNode, AddNode, AndNode, AttackNode, Base64DecodeNode, Base64EncodeNode, BooleanConstantNode, BranchNode, BreakBlockNode, BSplineNode, CacheNode, CanSeePositionNode, CeilNode, ClampNode, ClickSlotNode, CloseInventoryNode, CompareNode, CompressionNode, ConcatNode, CosNode, CreateVector3Node, DebounceNode, DecryptNode, DiscordWebhookNode, DistanceNode, DivideNode, DropItemNode, DropSlotNode, EncryptNode, EndsWithNode, FilterBotsNode, FindBlockNode, FindEntityNode, FindItemNode, FirstNode, FloorNode, ForEachBotNode, ForEachNode, FormatNode, FormulaNode, GateNode, GetArmorNode, GetAtNode, GetBiomeNode, GetBlockNode, GetBotByNameNode, GetBotInfoNode, GetBotsNode, GetBotStateNode, GetDimensionNode, GetEffectsNode, GetEntityStateNode, GetExperienceNode, GetGamemodeNode, GetHealthNode, GetHungerNode, GetInventoryNode, GetLightLevelNode, GetPersistentBotVariableNode, GetPersistentInstanceVariableNode, GetPositionNode, GetRotationNode, GetSelectedSlotNode, GetSessionBotVariableNode, GetSessionInstanceVariableNode, GetTargetBlockNode, GetTimeNode, GetVelocityNode, GetWeatherNode, HashNode, IndexOfNode, IsContainerOpenNode, IsEmptyNode, IsNullNode, JoinToStringNode, JsonArrayNode, JsonGetNode, JsonObjectNode, JsonParseNode, JsonSetNode, JsonStringifyNode, JumpNode, LastNode, LerpNode, ListContainsNode, ListLengthNode, LLMChatNode, LookAtNode, LoopNode, MaxNode, MinNode, ModuloNode, MoveBackwardNode, MoveForwardNode, MultiplyNode, NotNode, NumberConstantNode, OnBotInitNode, OnChatNode, OnContainerOpenNode, OnDamageNode, OnDeathNode, OnDisconnectNode, OnIntervalNode, OnJoinNode, OnPostEntityTickNode, OnPreEntityTickNode, OnScriptEndNode, OnScriptInitNode, OpenInventoryNode, OrNode, PathfindAwayFromNode, PathfindToNode, PlaceBlockNode, PowNode, PrintNode, RandomNode, RangeNode, RateLimitNode, RegexMatchNode, RegexReplaceNode, RepeatUntilNode, ReplaceNode, RespawnNode, ResultNode, RoundNode, SelectSlotNode, SendChatNode, SequenceNode, SetPersistentBotVariableNode, SetPersistentInstanceVariableNode, SetRotationNode, SetSessionBotVariableNode, SetSessionInstanceVariableNode, SinNode, SneakNode, SplitNode, SplitVector3Node, SprintNode, SqrtNode, StartsWithNode, StateNode, StrafeLeftNode, StrafeRightNode, StringConstantNode, StringContainsNode, StringLengthNode, SubstringNode, SubtractNode, SwingHandNode, SwitchNode, TanNode, TimestampNode, ToLowerCaseNode, ToNumberNode, ToStringNode, ToUpperCaseNode, TrimNode, UseItemNode, Vector3ConstantNode, WaitNode, WebFetchNode, XorNode

public abstract class AbstractScriptNode extends Object implements ScriptNode
Abstract base class for script nodes providing common utility methods.
  • Constructor Details

    • AbstractScriptNode

      public AbstractScriptNode()
  • Method Details

    • getInput

      protected <T> T getInput(Map<String, NodeValue> inputs, String name, T defaultValue)
      Helper method to get an input value with type casting. For non-JSON types like Vec3, extracts from the underlying JsonElement if possible.
    • getDoubleInput

      protected double getDoubleInput(Map<String, NodeValue> inputs, String name, double defaultValue)
      Helper method to get a double input value.
    • getIntInput

      protected int getIntInput(Map<String, NodeValue> inputs, String name, int defaultValue)
      Helper method to get an int input value.
    • getLongInput

      protected long getLongInput(Map<String, NodeValue> inputs, String name, long defaultValue)
      Helper method to get a long input value.
    • getFloatInput

      protected float getFloatInput(Map<String, NodeValue> inputs, String name, float defaultValue)
      Helper method to get a float input value.
    • getBooleanInput

      protected boolean getBooleanInput(Map<String, NodeValue> inputs, String name, boolean defaultValue)
      Helper method to get a boolean input value.
    • getStringInput

      protected String getStringInput(Map<String, NodeValue> inputs, String name, String defaultValue)
      Helper method to get a string input value.
    • getListInput

      protected List<NodeValue> getListInput(Map<String, NodeValue> inputs, String name)
      Helper method to get a list input value as NodeValues.
    • getStringListInput

      protected List<String> getStringListInput(Map<String, NodeValue> inputs, String name)
      Helper method to get a list of strings.
    • getBotInput

      protected @Nullable BotConnection getBotInput(Map<String, NodeValue> inputs)
      Helper method to get a bot from inputs. Returns null if the "bot" input is not set.
      Parameters:
      inputs - the node inputs
      Returns:
      the bot connection, or null if not provided
    • requireBot

      protected BotConnection requireBot(Map<String, NodeValue> inputs)
      Helper method to require a bot from inputs. The bot is typically provided automatically via the execution context from an upstream trigger node or ForEachBot node.
      Parameters:
      inputs - the node inputs (includes execution context values)
      Returns:
      the bot connection
      Throws:
      IllegalStateException - if no bot is available
    • getJsonInput

      protected @Nullable com.google.gson.JsonElement getJsonInput(Map<String, NodeValue> inputs, String name)
      Helper method to get a raw JsonElement from inputs.
    • runOnTickThread

      protected void runOnTickThread(NodeRuntime runtime, BotConnection bot, Runnable action)
      Helper method to run an action on the tick thread. When executing synchronously on the tick thread (from entity tick triggers), runs the action directly. Otherwise, defers via ControllingTask.singleTick().
      Parameters:
      runtime - the node runtime (provides sync/async context)
      bot - the bot connection
      action - the action to execute on the tick thread
    • result

      protected Map<String, NodeValue> result(String key, Object value)
      Helper method to create a result map with a single value.
    • results

      protected Map<String, NodeValue> results(Object... keyValuePairs)
      Helper method to create a result map with multiple values.
    • emptyResult

      protected Map<String, NodeValue> emptyResult()
      Helper method to create an empty result.
    • completedMono

      protected reactor.core.publisher.Mono<Map<String, NodeValue>> completedMono(Map<String, NodeValue> results)
      Helper method to create a completed Mono with results.
    • completedEmptyMono

      protected reactor.core.publisher.Mono<Map<String, NodeValue>> completedEmptyMono()
      Helper method to create a completed Mono with empty results.
    • delayedMono

      protected reactor.core.publisher.Mono<Map<String, NodeValue>> delayedMono(Duration delay, Map<String, NodeValue> results)
      Helper method to create a delayed Mono with results.
    • delayedEmptyMono

      protected reactor.core.publisher.Mono<Map<String, NodeValue>> delayedEmptyMono(Duration delay)
      Helper method to create a delayed Mono with empty results.