-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
New Commands API #55
base: master
Are you sure you want to change the base?
New Commands API #55
Conversation
Est-ce que les commandes auront une méthode “racine” ? Il serait pratique de pouvoir créer des commandes racines (par exemple |
Oui, je pensais avoir une annotation |
Autre remarque. Peut-on imaginer supporter d'une façon ou d'une autre (p.ex. une annotation Par exemple, il serait cool que quelque chose comme ceci : @Main
public void toast(String toast) {
assertEquals(toast, "Je suis un grille pain");
} fonctionne avec cet appel.
Ce genre de choses ont le don de rendre l'autocomplétion parfois tricky, cela dit (enfin, il faut analyser la ligne de commande pour voir si on est dans une chaîne en cours ou pas, quoi). |
Pour moi ça devrait être le comportement standard (sans devoir ajouter une annotation), vu que c'est la syntaxe standard des commandes il me semble maintenant. Pour parser la commande aussi je pensais utiliser le nouveau parseur officiel de Minecraft : https://github.com/Mojang/brigadier , comme ça on sera 100% standard et on pourra utiliser les |
J'ignorais que Brigadier gérait ça ; parfait alors ! Ce serait d'autant mieux, l'absence de support des |
6282592
to
a14bc55
Compare
85290da
to
02f02dd
Compare
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.
Some comments about the unknown command output (great idea by the way!).
...main/java/fr/zcraft/quartzlib/components/commands/exceptions/UnknownSubcommandException.java
Outdated
Show resolved
Hide resolved
...main/java/fr/zcraft/quartzlib/components/commands/exceptions/UnknownSubcommandException.java
Outdated
Show resolved
Hide resolved
...main/java/fr/zcraft/quartzlib/components/commands/exceptions/UnknownSubcommandException.java
Outdated
Show resolved
Hide resolved
…rest utility method.
dd84229
to
c2a72c3
Compare
(WIP Draft)
To-Do list:
Handle overloads with the same number of parameters of different types
@CommandMethod
annotation with priority argument to change thisHandle fetching argument names:
@Param
annotation with name argumentThrow proper exception for missing argument(s) (for non-overriden methods)
e.g. "Missing argument: /toaster add ",
Throw proper exception for extra argument(s) (for non-overriden methods)
e.g. "Unexpected extra argument: /toaster add 5 foo", (foo in red)
Throw proper exception for invalid argument(s)
e.g. "Invalid argument: /toaster add foo" (foo in red)
" count: "foo" is not a number."
Standardize CommandException display formatting (using overridable methods such as "ErrorMessage", "Hint", etc.)
Find a smart way to display error messages about missing/extra/invalid arguments when there are multiple overloads that mismatch for different reasons
If multiple are found, order them using Levenshtein Distance?
Allow ArgumentType to consume multiple arguments (e.g. Location would consume "X Y Z")
Add an override consuming an
ArgumentList
instead ofString
(default impl. forwards to the one consumingString
Not consuming a single argument (without throwing) should be a hard error
Add an async ArgumentType variant (e.g. OfflinePlayer when a name is given and an API call has to be made to Mojang services)
Add support for flags:
@Flag
annotation with short and long names (at least one should be specified)Add support for multiple-flags:
@Flag(multiple = true)
Add support for required flags (can be multiple as well):
@Flag(required = true)
Add native type handlers (more can be added):