-
Notifications
You must be signed in to change notification settings - Fork 395
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
[Suggestion] Optional Arguments #110
Comments
Are redirects not a solution for this? |
@Gamebuster19901 the point is: You are required to write duplicated implementations for every single Optional argument. Just look at my code example that I have done and replicate it and look how much worse it looks and is to maintain if you don't have these features. I dunno what you think but if you have 8 versions to maintain and have to do fixes for one or two functions that have to interact with that it just gets bad. And it is quite sad that Mojang doesn't see the Benefit of such a function that doesn't have ANY downsides. |
Giving this a friendly bump because this would be lovely |
Yes, please! We need this! |
This would make this type of development significantly faster. |
Honestly this is just a very tiny QoL change that is "Optional" yet mojang hasn't included. |
Ok this is a bit rough to start.
When commands in Minecraft are created, you have either 2 ways of creating commands that are executed.
Either implement every single execution itself. (If you have 5 optional parameters that's getting annoying really quickly)
Or you implement a CommandContext Wrapper that basically does this:
It would be nice if you could check if arguments have been defined or allow to getOrDefault.
This is mainly there to reduce code. Implementing everything 5 times. Even if Lambdas are being used that call a helper function that basically does the same.
Instead this could look a lot cleaner.
Here is a example with my CommandBuilder & Command Wrapper
The Reason for hasValue is used for the GenShape is a example. What if the software that the CommandContext uses only exists on 1 side. It can detect if a single side exists, or if dual sided implementation is present.
Or in modding terms: ServerOnly Mods.
This is how I would implement it.
If you want I can make it a offical PR, or you can just grab the implementation.
Reference Code: https://github.com/Mojang/brigadier/blob/master/src/main/java/com/mojang/brigadier/context/CommandContext.java#L81
The text was updated successfully, but these errors were encountered: