Package org.spongepowered.api.command
Interface CommandResult
-
public interface CommandResultRepresents the result of a command in Sponge.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceCommandResult.BuilderBuildsCommandResults.static interfaceCommandResult.Factory
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static CommandResult.Builderbuilder()Creates a builder that createsCommandResults.static CommandResulterror(Component errorMessage)Builds an empty result that will prompt the command manager to send an error message without throwing an exception.Optional<Component>errorMessage()If present, returns the error message associated with this result.booleanisSuccess()Gets whether the command executed successfully.intresult()Gets the integer result returned by the command that executed.static CommandResultsuccess()Builds a result that indicates success (whereCommandResult.Builder.result(int)is set to 1.
-
-
-
Method Detail
-
builder
static CommandResult.Builder builder()
Creates a builder that createsCommandResults.- Returns:
- The
CommandResult.Builder
-
success
static CommandResult success()
Builds a result that indicates success (whereCommandResult.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:
trueif so.
-
result
int result()
Gets the integer result returned by the command that executed.- Returns:
- The result.
-
-