feat: `@Length` Annotation for String Parameters
gmitch215 opened this issue · comments
Hello,
I am proposing to add a @Length
annotation that would create a minimum/maximum length for Strings. I'm pretty sure this is natively supported by brigadier, but I'm not sure. I couldn't find an existing annotation that exists for this purpose, so I'm proposing a new one.
It would look like this:
public @interface Length {
int min() default 0;
int max() default Integer.MAX_VALUE; // Something like that
}
Could be used in scenarios like this:
@Command("nick")
@Description("Set a Player's Nickname")
public void nickPlayer(Player player, @Length(min = 3, max = 32) String name) {
player.setDisplayName(name);
}
Also: I would recommend creating a build script that automatically updates the JavaDocs instead of manually copying files.
This sounds like an excellent use case for parameter validators, see https://github.com/Revxrsal/Lamp/wiki/Parameter-validators. There's a good chance it may be natively added later as it could be used by brigadier.
Also: I would recommend creating a build script that automatically updates the JavaDocs instead of manually copying files.
Thanks, I'll take a look. They are currently neglected as I believe most people either look at the wiki, examples, or inspect code themselves.