New event. CommandProcessEvent#1333
New event. CommandProcessEvent#1333djxy wants to merge 5 commits intoSpongePowered:bleedingfrom djxy:bleeding
Conversation
| * @param arguments The arguments | ||
| * @param command The command | ||
| * @return A new send command event | ||
| */ |
There was a problem hiding this comment.
If these were not automatically generated by the tool, they probably should be to match the other events.
There was a problem hiding this comment.
How can I generate them automatically?
There was a problem hiding this comment.
run ./gradlew genEventImpl licenseFormat in SpongeAPI
|
Removed SendCommandEvent and moved the setters of CommandProcessEvent to CommandProcessEvent.Pre |
| * | ||
| * @param result The result of the command | ||
| */ | ||
| void setResult(CommandResult result); |
There was a problem hiding this comment.
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
does not return an OptionalThere was a problem hiding this comment.
What about CommandResult.empty()? Or maybe CommandResult.cancelled() (we'll have to create one)
|
So, posting here everything I have in mind
PS. What about renaming the event from (Github, will you stop formatting the comment for me 😦 ) |
|
You can't always get |
|
We can check if But problem still remains - it's just a wrapper around And after thinking some time, I can't think of any convenient way of getting what argument represents without rewriting a lot of code. Right now |
And it just occurred to me that if we get CommandMapping from So, after all that my only suggestions would be:
|
|
Need a judgement call on this one. |
|
I think this event could be nice to have. We will know when a command is sent by a player before and after its execution. If you want to merge it, I will recreate a pull request because I deleted the repositories for SpongeAPI and SpongeCommon. I could do that tonight. It will contains the same code. |
|
Yeah, this functionality would be useful. Only issue I had was already mentioned by @ryantheleach. Once that's resolved this should be good to merge. It should be relatively easy to recreate the changes -- GH keeps the commit even though its been deleted, so you can checkout the commit you already had from the SpongePowered/SpongeAPI repository. |
|
@djxy I can't clone your repository to look at merging this PR as it's marked as "private" or "unknown". |
|
I deleted the repository when I cleaned my account. I can recreate it if you want. |
I needed an event to handle the process of a command before and after that happen in the same tick. So I created this new event to handle that.
When some commands are fired by some players, I need to disable some functionalities. /help is one of them.
Currently there is only one event for when a command is send and it is SendCommandEvent. The commandResult isn't good.
https://github.com/SpongePowered/SpongeCommon/blob/bleeding/src/main/java/org/spongepowered/common/command/SpongeCommandManager.java#L258
SpongeCommon: SpongePowered/Sponge#888