-
-
Notifications
You must be signed in to change notification settings - Fork 339
New event. CommandProcessEvent #1333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e255c89
40da707
4853a15
eaa6160
2e491ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -29,29 +29,60 @@ | |||
| import org.spongepowered.api.event.Event; | ||||
|
|
||||
| /** | ||||
| * Fired when a command is sent | ||||
| * Fired when a command is processed | ||||
| */ | ||||
| public interface SendCommandEvent extends Event, Cancellable { | ||||
| public interface CommandProcessEvent extends Event { | ||||
|
|
||||
| /** | ||||
| * Get the command as a string, without any sort of command prefix. | ||||
| * | ||||
| * <p>For example, if the message was {@code /example bob 3 -f}, then | ||||
| * the command would be {@code example}.</p> | ||||
| * | ||||
| * @return The command | ||||
| * Fired before the command is processed | ||||
| */ | ||||
| String getCommand(); | ||||
| public interface Pre extends CommandProcessEvent, Cancellable { | ||||
|
|
||||
| /** | ||||
| * Set the command as a string, without any sort of command prefix. | ||||
| * | ||||
| * <p>For example, if the message was {@code /example bob 3 -f}, then | ||||
| * the command would be {@code example}.</p> | ||||
| * | ||||
| * @param command The command | ||||
| */ | ||||
| void setCommand(String command); | ||||
|
|
||||
| /** | ||||
| * Set the arguments as a string. | ||||
| * | ||||
| * <p>For example, if the message was {@code /example bob 3 -f}, then | ||||
| * the arguments would be {@code bob 3 -f}.</p> | ||||
| * | ||||
| * @param arguments The arguments | ||||
| */ | ||||
| void setArguments(String arguments); | ||||
|
|
||||
| } | ||||
|
|
||||
| /** | ||||
| * Fired after the command is processed | ||||
| */ | ||||
| public interface Post extends CommandProcessEvent { | ||||
|
|
||||
| /** | ||||
| * The result of the command. | ||||
| * | ||||
| * @return The result of the command | ||||
| */ | ||||
| CommandResult getResult(); | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd move this to CommandProcessEvent. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? This event is fired after the command is processed, which allows a result to be present; Pre is fired before the command is processed, meaning no result has been produced yet.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See the other comment. https://github.com/SpongePowered/SpongeAPI/pull/1333/files#r75581844 |
||||
|
|
||||
| } | ||||
|
|
||||
| /** | ||||
| * Set the command as a string, without any sort of command prefix. | ||||
| * Get the command as a string, without any sort of command prefix. | ||||
| * | ||||
| * <p>For example, if the message was {@code /example bob 3 -f}, then | ||||
| * the command would be {@code example}.</p> | ||||
| * | ||||
| * @param command The command | ||||
| * @return The command | ||||
| */ | ||||
| void setCommand(String command); | ||||
| String getCommand(); | ||||
|
|
||||
| /** | ||||
| * Get the arguments as a string. | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The removal of setResult from the Pre event, means that plugins which provide command redirection / rewriting will be unable to return the result of the original processed command, when the event is cancelled. Whether this is a good or bad thing however I can't decide. You could argue that instead of cancelling, you should just rewrite the redirected command into the original and let it continue if you actually need the CommandResult. But without setting a result, cancelling would have to make an assumption about the appropriate CommandResult to return, as
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about |
||||
|
|
@@ -63,28 +94,4 @@ public interface SendCommandEvent extends Event, Cancellable { | |||
| */ | ||||
| String getArguments(); | ||||
|
|
||||
| /** | ||||
| * Set the arguments as a string. | ||||
| * | ||||
| * <p>For example, if the message was {@code /example bob 3 -f}, then | ||||
| * the arguments would be {@code bob 3 -f}.</p> | ||||
| * | ||||
| * @param arguments The arguments | ||||
| */ | ||||
| void setArguments(String arguments); | ||||
|
|
||||
| /** | ||||
| * The result of the command. | ||||
| * | ||||
| * @return The result of the command | ||||
| */ | ||||
| CommandResult getResult(); | ||||
|
|
||||
| /** | ||||
| * Sets the result of the command. | ||||
| * | ||||
| * @param result The result of the command | ||||
| */ | ||||
| void setResult(CommandResult result); | ||||
|
|
||||
| } | ||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this differ to
https://github.com/SpongePowered/SpongeAPI/blob/fa7ce8e776691966b64a893ee09820799dfaa4df/src/main/java/org/spongepowered/api/event/command/SendCommandEvent.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the setResult() method inside After could be removed.