2929import org .spongepowered .api .command .exception .CommandException ;
3030import org .spongepowered .api .command .parameter .CommandContext ;
3131import org .spongepowered .api .command .parameter .Parameter ;
32- import org .spongepowered .api .command .source .CommandSource ;
3332import org .spongepowered .api .event .cause .Cause ;
3433import org .spongepowered .api .event .cause .EventContext ;
3534import org .spongepowered .api .event .cause .EventContextKeys ;
3635import org .spongepowered .api .plugin .PluginContainer ;
36+ import org .spongepowered .api .service .permission .Subject ;
3737import org .spongepowered .api .text .Text ;
3838import org .spongepowered .api .util .ResettableBuilder ;
3939import org .spongepowered .api .world .Location ;
6363 * as required. This <em>may</em> enable the use of client side command
6464 * completions, if the implementation is equipped to do so.</p>
6565 *
66- * <p>Commands in Sponge are provided with a {@link Cause }, which explains
67- * who <strong>directly</strong> invoked the command. In line with causes used
68- * in events, you may assume that the {@link Cause#root()} is the
69- * <strong>intended</strong> direct invoker.</p>
66+ * <p>Commands in Sponge are provided with a {@link CommandCause }, which
67+ * provides a {@link Cause} explains who <strong>directly</strong> invoked the
68+ * command. In line with causes used in events, you may assume that the
69+ * {@link Cause#root()} is the <strong>intended</strong> direct invoker.</p>
7070 *
7171 * <p>It is <em>very</em> important to note that no object in the {@link Cause}
7272 * is guaranteed to be a traditional "command source" - a plugin may invoke a
8686 * be handled, in addition to using the provided cause stack:</p>
8787 *
8888 * <ul>
89- * <li>{@link EventContextKeys#MESSAGE_CHANNEL }, which indicates the
89+ * <li>{@link EventContextKeys#MESSAGE_TARGET }, which indicates the
9090 * where messages that should be sent back to the invoker should be sent
9191 * to (typically messages indicating the status of the command execution);
92- * and, </li>
92+ * </li>
9393 * <li>{@link EventContextKeys#SUBJECT}, which indicates the subject that
94- * should be subjected to any permission checks.</li>
94+ * should be subjected to any permission checks;</li>
95+ * <li>{@link EventContextKeys#LOCATION}, which indicates the location that
96+ * the command should be assumed to be executed around; and,</li>
97+ * <li>{@link EventContextKeys#BLOCK_TARGET}, which indicates the block that
98+ * the command should take into account when executing.</li>
9599 * </ul>
96100 */
97101public interface Command {
@@ -111,31 +115,31 @@ static Builder builder() {
111115 * <p>The implementing class must perform the necessary permission
112116 * checks.</p>
113117 *
114- * @param cause The {@link Cause } of the invocation of command
118+ * @param cause The {@link CommandCause } of the invocation of command
115119 * @param arguments The raw arguments for this command
116120 * @return The result of a command being processed
117121 * @throws CommandException Thrown on a command error
118122 */
119- CommandResult process (Cause cause , String arguments ) throws CommandException ;
123+ CommandResult process (CommandCause cause , String arguments ) throws CommandException ;
120124
121125 /**
122126 * Gets a list of suggestions based on input.
123127 *
124128 * <p>If a suggestion is chosen by the user, it will replace the last
125129 * word.</p>
126130 *
127- * @param cause The {@link Cause } of the command
131+ * @param cause The {@link CommandCause } of the command
128132 * @param arguments The arguments entered up to this point
129133 * @param targetPosition The position the source is looking at when
130134 * performing tab completion
131135 * @return A list of suggestions
132136 * @throws CommandException Thrown if there was a parsing error
133137 */
134- List <String > getSuggestions (Cause cause , String arguments , @ Nullable Location targetPosition ) throws CommandException ;
138+ List <String > getSuggestions (CommandCause cause , String arguments , @ Nullable Location targetPosition ) throws CommandException ;
135139
136140 /**
137141 * Test whether this command can probably be executed given this
138- * {@link Cause} and {@link CommandSource} .
142+ * {@link Cause}.
139143 *
140144 * <p>If implementations are unsure if the command can be executed by
141145 * the source, {@code true} should be returned. Return values of this method
@@ -145,7 +149,7 @@ static Builder builder() {
145149 * @param cause The {@link Cause} to check
146150 * @return Whether this command will execute
147151 */
148- boolean canExecute (Cause cause );
152+ boolean canExecute (CommandCause cause );
149153
150154 /**
151155 * Gets a short one-line description of this command.
@@ -155,7 +159,7 @@ static Builder builder() {
155159 * @param cause The {@link Cause} of the help request
156160 * @return A description
157161 */
158- Optional <Text > getShortDescription (Cause cause );
162+ Optional <Text > getShortDescription (CommandCause cause );
159163
160164 /**
161165 * Gets a longer formatted help message about this command.
@@ -172,7 +176,7 @@ static Builder builder() {
172176 * @param cause The {@link Cause} of the help request
173177 * @return A help text
174178 */
175- Optional <Text > getHelp (Cause cause );
179+ Optional <Text > getHelp (CommandCause cause );
176180
177181 /**
178182 * Gets the usage string of this command.
@@ -185,7 +189,7 @@ static Builder builder() {
185189 * @param cause The {@link Cause} of the help request
186190 * @return A usage string
187191 */
188- Text getUsage (Cause cause );
192+ Text getUsage (CommandCause cause );
189193
190194 /**
191195 * A {@link Command} that has distinct steps for parsing arguments and
@@ -208,13 +212,13 @@ interface Parameterized extends Command, CommandExecutor {
208212 * @param arguments The argument {@link String}
209213 * @return The {@link CommandContext}
210214 */
211- CommandContext parseArguments (Cause cause , String arguments );
215+ CommandContext parseArguments (CommandCause cause , String arguments );
212216
213217 /**
214218 * Processes the command by parsing the arguments, then
215219 * executing command based on these arguments.
216220 *
217- * <p>By default, this will call {@link #parseArguments(Cause , String)}
221+ * <p>By default, this will call {@link #parseArguments(CommandCause , String)}
218222 * and pass the resulting {@link CommandContext} to
219223 * {@link #execute(CommandContext)}.</p>
220224 *
@@ -223,7 +227,7 @@ interface Parameterized extends Command, CommandExecutor {
223227 * @return The result of a command being processed
224228 * @throws CommandException Thrown on a command error
225229 */
226- default CommandResult process (Cause cause , String arguments ) throws CommandException {
230+ default CommandResult process (CommandCause cause , String arguments ) throws CommandException {
227231 return execute (parseArguments (cause , arguments ));
228232 }
229233
@@ -362,7 +366,7 @@ default Builder parameters(Iterable<Parameter> parameters) {
362366 * relevant description based on the supplied {@link Cause}
363367 * @return This builder, for chaining
364368 */
365- Builder setExtendedDescription (Function <Cause , Optional <Text >> extendedDescriptionFunction );
369+ Builder setExtendedDescription (Function <CommandCause , Optional <Text >> extendedDescriptionFunction );
366370
367371 /**
368372 * Provides the description for this command.
@@ -382,18 +386,17 @@ default Builder setExtendedDescription(@Nullable Text extendedDescription) {
382386
383387 /**
384388 * Provides a simple description for this command, typically no more
385- * than one line, which is dependent on the {@link Cause} and the
386- * responsible {@link CommandSource} that requests it.
389+ * than one line, which is dependent on the {@link Cause} that requests
390+ * it.
387391 *
388392 * <p>Fuller descriptions should be provided through
389393 * {@link #setExtendedDescription(Function)}</p>
390394 *
391395 * @param descriptionFunction A function that provides a relevant
392- * description based on the supplied {@link Cause} and
393- * {@link CommandSource}
396+ * description based on the supplied {@link Cause}
394397 * @return This builder, for chaining
395398 */
396- Builder setShortDescription (Function <Cause , Optional <Text >> descriptionFunction );
399+ Builder setShortDescription (Function <CommandCause , Optional <Text >> descriptionFunction );
397400
398401 /**
399402 * Provides a simple description for this command, typically no more
@@ -413,8 +416,9 @@ default Builder setShortDescription(@Nullable Text description) {
413416 }
414417
415418 /**
416- * The permission that a {@link CommandSource} requires to run this
417- * command, or {@code null} if no permission is required.
419+ * The permission that the responsible {@link Subject} in the given
420+ * {@link Cause} requires to run this command, or {@code null} if no
421+ * permission is required.
418422 *
419423 * <p>For more control over whether a command can be executed, use
420424 * {@link #setExecutionRequirements(Predicate)}. However, note that
@@ -423,7 +427,7 @@ default Builder setShortDescription(@Nullable Text description) {
423427 * during execution.</p>
424428 *
425429 * <p>Any permission checks set here will be performed during the
426- * {@link Command#canExecute(Cause )}.</p>
430+ * {@link Command#canExecute(CommandCause )}.</p>
427431 *
428432 * <p>Calling this repeatedly will not add additional permission
429433 * checks, instead replacing the permission check. If multiple
@@ -438,21 +442,21 @@ default Builder setShortDescription(@Nullable Text description) {
438442
439443 /**
440444 * Sets a function that determines what is required of the provided
441- * {@link Cause} and {@link CommandSource} before this command executes.
445+ * {@link Cause} before this command executes.
442446 *
443447 * <p>Any requirements here are in addition to the permission check
444448 * from {@link #setPermission(String)}</p>
445449 *
446450 * <p>Any requirements set here will be performed during the
447- * {@link Command#canExecute(Cause )}.</p>
451+ * {@link Command#canExecute(CommandCause )}.</p>
448452 *
449453 * <p>Calling this repeatedly will not add additional checks, instead
450454 * replacing the previous requirements.</p>
451455 *
452456 * @param executionRequirements A function that sets the
453457 * @return This builder, for chaining
454458 */
455- Builder setExecutionRequirements (@ Nullable Predicate <Cause > executionRequirements );
459+ Builder setExecutionRequirements (@ Nullable Predicate <CommandCause > executionRequirements );
456460
457461 /**
458462 * Builds this command, creating a {@link Command.Parameterized}
0 commit comments