Package org.spongepowered.api.command
Interface CommandResult
public interface CommandResult
Represents the result of a command in Sponge.
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic CommandResult.Builder
builder()
Creates a builder that createsCommandResult
s.static CommandResult
Builds an empty result that will prompt the command manager to send an error message without throwing an exception.If present, returns the error message associated with this result.boolean
Gets whether the command executed successfully.int
result()
Gets the integer result returned by the command that executed.static CommandResult
success()
Builds a result that indicates success (whereCommandResult.Builder.result(int)
is set to 1.
-
Method Details
-
builder
Creates a builder that createsCommandResult
s.- Returns:
- The
CommandResult.Builder
-
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
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
If present, returns the error message associated with this result.- Returns:
- The error
Component
-