Package org.spongepowered.api.command
Interface CommandResult
-
public interface CommandResult
Represents the result of a command in Sponge.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
CommandResult.Builder
BuildsCommandResult
s.static interface
CommandResult.Factory
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static CommandResult.Builder
builder()
Creates a builder that createsCommandResult
s.static CommandResult
error(Component errorMessage)
Builds an empty result that will prompt the command manager to send an error message without throwing an exception.java.util.Optional<Component>
errorMessage()
If present, returns the error message associated with this result.boolean
isSuccess()
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 Detail
-
builder
static CommandResult.Builder builder()
Creates a builder that createsCommandResult
s.- 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:
true
if so.
-
result
int result()
Gets the integer result returned by the command that executed.- Returns:
- The result.
-
-