Interface BasicCommand

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@Experimental @NullMarked @FunctionalInterface public interface BasicCommand
Implementing this interface allows for easily creating "Bukkit-style" String[] args commands. The implementation handles converting the command to a representation compatible with Brigadier on registration, usually in the form of /commandlabel <greedy_string>.
  • Method Details

    • execute

      @OverrideOnly void execute(CommandSourceStack commandSourceStack, String[] args)
      Executes the command with the given CommandSourceStack and arguments.
      Parameters:
      commandSourceStack - the commandSourceStack of the command
      args - the arguments of the command ignoring repeated spaces
    • suggest

      @OverrideOnly default Collection<String> suggest(CommandSourceStack commandSourceStack, String[] args)
      Suggests possible completions for the given command CommandSourceStack and arguments.
      Parameters:
      commandSourceStack - the commandSourceStack of the command
      args - the arguments of the command including repeated spaces
      Returns:
      a collection of suggestions
    • canUse

      @OverrideOnly default boolean canUse(CommandSender sender)
      Checks whether a command sender can receive and run the root command.
      Parameters:
      sender - the command sender trying to execute the command
      Returns:
      whether the command sender fulfills the root command requirement
      See Also:
    • permission

      @OverrideOnly default @Nullable String permission()
      Returns the permission for the root command used in canUse(CommandSender) by default.
      Returns:
      the permission for the root command used in canUse(CommandSender)