Interface CommandResult


  • public interface CommandResult
    Represents the result of a command in Sponge.
    • Method Detail

      • success

        static CommandResult success()
        Builds a result that indicates success (where CommandResult.Builder.result(int) is set to 1.

        Note that a successful result is one where the command has done what is expected of it. This should be used in place of "empty" from previous API iterations. If an error condition should be reported, use error(Component) instead, which will allow the system to react accordingly.

        Returns:
        The CommandResult
      • error

        static CommandResult error​(Component errorMessage)
        Builds an empty result that will prompt the command manager to send an error message without throwing an exception.
        Parameters:
        errorMessage - The error message to send
        Returns:
        The CommandResult
      • isSuccess

        boolean isSuccess()
        Gets whether the command executed successfully.
        Returns:
        true if so.
      • result

        int result()
        Gets the integer result returned by the command that executed.
        Returns:
        The result.
      • errorMessage

        java.util.Optional<Component> errorMessage()
        If present, returns the error message associated with this result.
        Returns:
        The error Component