Add greedy charset option to string argument#131
Open
Owen1212055 wants to merge 3 commits into
Open
Conversation
Fortern
added a commit
to Fortern/brigadier
that referenced
this pull request
Aug 12, 2024
StillLutto
approved these changes
Dec 4, 2024
StillLutto
left a comment
There was a problem hiding this comment.
Looks good, please accept this PR. This would be one of the most, if not the most, useful things for plugin developers using commands.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This implements the concept of "greedy charsets" for brigadier string argument types.
Currently, word / quotable phrase arguments have a strict charset. For quotable phrase arguments, you can simply wrap the argument in quotes to allow these characters. However, for word arguments, you cannot use other characters at all. This is quite limiting, as even characters as simple as = are not allowed. This also blocks pretty much all international characters, making these argument types inconvenient to use.
In order to keep backward compatibility, a new "greedy charset" field has been added to the string argument types. This allows words/quoted strings to allow a much wider range of characters. StringReader also now has "greedy" methods, which will act as a way to have this functionality in other custom argument types if wanted. This means that any previous use of the argument/StringReader methods will use the legacy behavior.
Word argument
Before:
Note: Word arguments can't even be quoted, so it's impossible to use these characters.

After:
(with greedy charset)

String argument
Before:
After:
(with greedy charset)


Note, that we no longer need to wrap the argument in quotes with these characters.
Fixes
Fixes #103
Fixes #44