Introduce CommandError Set - #3447
Conversation
|
Would it be possible to remove the Both server and user mode: Only user mode: Only server mode (I don't think there are any cases?) |
Maybe its just me but I want a command to actually think about why they don't support console etc, so I like it more if its "harder" to be restrictive. Also the Source union may not stay at what it currently is. I could see that for example some kind of Entity / Block Source is also added. Also, some commands may only support console on specifc parts. with the error they can (if entered a "wrong" path) just return that and a message is displayed. I am also thinking about adding a |
Excessive boilerplate is not a way to make API less error prone.
For future extensions, implementation can be adjusted accordingly, changes in the source code of command system will be required anyway, since union will have to change. Honestly I am puzzled about push for explicit source checks compared to #3336 - so, should it be more automatic or more explicit? Security doesn't require explicit, fine grained control, but function arguments do? |
|
One nice thing about the union is that it can have functions (like it currently already has 2) so that commands don't really have to change unless they don't support something. I could see adding support so you can do either: At the end I can see that this is boilerplate for the Worldedit commands, and I am fine if we add the option to accept |
|
I thought about this for a bit, and I tend to agree with Argmaster, letting the type system handle the source selection is much safer than relying on the command creator to check their sources correctly (which could lead to a server crash). Extending on argmasters idea I propose the following system: The command system switches over the source, for each case it looks for a function of matching type and name Though honestly I'm not 100% sure if this is the best approach, it seems problematic with all the commands that take an optional user. Another idea could be to put the source inside the parser struct, e.g. |
Does what was proposed in this review #3223 (comment)