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

  • Type Parameters:
    T - the type to expect from the command context

    public class NodeBuilder<T extends me.lucyy.squirtgun.platform.audience.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 Detail

      • NodeBuilder

        public NodeBuilder()
    • Method Detail

      • 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.