Skip to content

Commit befe359

Browse files
committed
Remove CommandResult#empty()
* This was just causing confusion as it indicated an error condition to the processor. Instead, if you have an error condition, you should indicate it using CommandResult#error(...).
1 parent 886e99c commit befe359

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/main/java/org/spongepowered/api/command/CommandResult.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,21 @@ static Builder builder() {
4545
}
4646

4747
/**
48-
* Builds a result that indicates successes.
48+
* Builds a result that indicates success (where {@link Builder#result(int)}
49+
* is set to 1.
50+
*
51+
* <p>Note that a successful result is one where the command has done what
52+
* is expected of it. This should be used in place of "empty" from previous
53+
* API iterations. If an error condition should be reported, use
54+
* {@link #error(Component)} instead, which will allow the system to react
55+
* accordingly.</p>
4956
*
5057
* @return The {@link CommandResult}
5158
*/
5259
static CommandResult success() {
5360
return CommandResults.SUCCESS;
5461
}
5562

56-
/**
57-
* Builds an empty result.
58-
*
59-
* @return The {@link CommandResult}
60-
*/
61-
static CommandResult empty() {
62-
return CommandResults.EMPTY;
63-
}
64-
6563
/**
6664
* Builds an empty result that will prompt the command manager to send an
6765
* error message without throwing an exception.
@@ -105,7 +103,8 @@ interface Builder extends org.spongepowered.api.util.Builder<CommandResult, Buil
105103
*
106104
* <ul>
107105
* <li>A positive value indicates successful execution,</li>
108-
* <li>Zero indicates the command didn't fulfil its task</li>
106+
* <li>Zero (generally) indicates the command didn't fulfil its
107+
* task, though that is not necessarily an error condition.</li>
109108
* <li>A negative value is undefined in the API, if returned, the
110109
* effects are implementation specific.</li>
111110
* </ul>
@@ -116,11 +115,12 @@ interface Builder extends org.spongepowered.api.util.Builder<CommandResult, Buil
116115
Builder result(int result);
117116

118117
/**
119-
* Sets or removes the error message to return to the user without
120-
* throwing an exception.
118+
* Sets the built result to report an error, with an optional error
119+
* message.
121120
*
122121
* <p>If this is set, then the command parser will send this message to
123-
* the command invoker.</p>
122+
* the command invoker. Otherwise, the parser will report an unknown
123+
* exception.</p>
124124
*
125125
* @param errorMessage The message to send to the user.
126126
* @return This builder, for chaining

src/main/java/org/spongepowered/api/command/CommandResults.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public final class CommandResults {
3737
/**
3838
* Indicates that the command executed but was unable to carry out its task.
3939
*/
40-
public static final CommandResult EMPTY = CommandResult.builder().build();
40+
public static final CommandResult UNKNOWN_ERROR = CommandResult.builder().error(null).build();
4141

4242
private CommandResults() {
4343
throw new AssertionError("You shouldn't be trying to instantiate this");

0 commit comments

Comments
 (0)