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, CeilNode, ClampNode, CompareNode, CompressionNode, ConcatNode, CosNode, CreateVector3Node, DebounceNode, DecryptNode, DiscordWebhookNode, DistanceNode, DivideNode, EncryptNode, EndsWithNode, FilterBotsNode, FindBlockNode, FindEntityNode, FirstNode, FloorNode, ForEachBotNode, ForEachNode, FormatNode, FormulaNode, GateNode, GetArmorNode, GetAtNode, GetBiomeNode, GetBlockNode, GetBotByNameNode, GetBotInfoNode, GetBotsNode, GetBotStateNode, GetDimensionNode, GetEffectsNode, GetExperienceNode, GetGamemodeNode, GetHealthNode, GetHungerNode, GetInventoryNode, GetLightLevelNode, GetPersistentBotVariableNode, GetPositionNode, GetRotationNode, GetSelectedSlotNode, GetSessionBotVariableNode, GetTargetBlockNode, GetTimeNode, GetVelocityNode, GetWeatherNode, HashNode, IndexOfNode, IsEmptyNode, IsNullNode, JoinToStringNode, JsonArrayNode, JsonGetNode, JsonObjectNode, JsonParseNode, JsonSetNode, JsonStringifyNode, JumpNode, LastNode, LerpNode, ListContainsNode, ListLengthNode, LLMChatNode, LookAtNode, LoopNode, MaxNode, MinNode, ModuloNode, MultiplyNode, NotNode, NumberConstantNode, OnBotInitNode, OnChatNode, OnDamageNode, OnDeathNode, OnIntervalNode, OnJoinNode, OnScriptEndNode, OnScriptInitNode, OnTickNode, OrNode, PathfindToNode, PlaceBlockNode, PowNode, PrintNode, RandomNode, RangeNode, RateLimitNode, RegexMatchNode, RegexReplaceNode, ReplaceNode, RoundNode, SelectSlotNode, SendChatNode, SequenceNode, SetPersistentBotVariableNode, SetRotationNode, SetSessionBotVariableNode, SinNode, SneakNode, SplitNode, SplitVector3Node, SprintNode, SqrtNode, StartsWithNode, StateNode, StringConstantNode, StringContainsNode, StringLengthNode, SubstringNode, SubtractNode, 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.
    • 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.