Class NodeBuilder<T extends me.lucyy.squirtgun.platform.PermissionHolder>

java.lang.Object
me.lucyy.squirtgun.command.node.NodeBuilder<T>
Type Parameters:
T - the type to expect from the command context

public class NodeBuilder<T extends me.lucyy.squirtgun.platform.PermissionHolder>
extends java.lang.Object
A builder to build a node. The minimum required fields are name and an execute function.
Since:
2.0.0
  • Constructor Summary

    Constructors
    Constructor Description
    NodeBuilder()  
  • Method Summary

    Modifier and Type Method Description
    NodeBuilder<T> arguments​(@NotNull CommandArgument<?>... arguments)
    Adds arguments to this node.
    CommandNode<T> build()
    Builds this node, throwing a NullPointerException if an argument is incorrect or missing.
    NodeBuilder<T> description​(@NotNull java.lang.String description)
    Sets this node's description.
    NodeBuilder<T> executes​(@NotNull java.util.function.Function<CommandContext<T>,​@Nullable net.kyori.adventure.text.Component> executes)
    Sets the function to execute this node.
    NodeBuilder<T> name​(@NotNull java.lang.String name)
    Sets this node's name.
    NodeBuilder<T> next​(@Nullable CommandNode<T> next)
    Sets the next node in the chain.
    NodeBuilder<T> permission​(@Nullable java.lang.String permission)
    Sets this node's required permission.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • NodeBuilder

      public NodeBuilder()
  • Method Details

    • name

      public NodeBuilder<T> name​(@NotNull @NotNull java.lang.String name)
      Sets this node's name.
      Parameters:
      name - the new name to set
      Returns:
      this
    • description

      public NodeBuilder<T> description​(@NotNull @NotNull java.lang.String description)
      Sets this node's description.
      Parameters:
      description - the new description to set - this should be a short, 1-line sentence
      Returns:
      this
    • permission

      public NodeBuilder<T> permission​(@Nullable @Nullable java.lang.String permission)
      Sets this node's required permission.
      Parameters:
      permission - the required permission or null if none is needed
      Returns:
      this
    • executes

      public NodeBuilder<T> executes​(@NotNull @NotNull java.util.function.Function<CommandContext<T>,​@Nullable net.kyori.adventure.text.Component> executes)
      Sets the function to execute this node.
      Parameters:
      executes - the function. It should return a component to display to the sender. This may be null, in which case nothing will be sent.
      Returns:
      this
    • next

      public NodeBuilder<T> next​(@Nullable @Nullable CommandNode<T> next)
      Sets the next node in the chain. Typically you don't need this, the default value of null will suffice.
      Parameters:
      next - a possibly null next node
      Returns:
      this
    • arguments

      public NodeBuilder<T> arguments​(@NotNull @NotNull CommandArgument<?>... arguments)
      Adds arguments to this node.
      Parameters:
      arguments - arguments to add, in order, to the list
      Returns:
      this
    • build

      public CommandNode<T> build()
      Builds this node, throwing a NullPointerException if an argument is incorrect or missing.
      Returns:
      a node built from the specified parameters.