Skip to content
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

Add greedy charset option to string argument #131

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Owen1212055
Copy link

@Owen1212055 Owen1212055 commented May 6, 2023

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:

image

Note: Word arguments can't even be quoted, so it's impossible to use these characters.
image

After:

(with greedy charset)
image

String argument

Before:

image
image

After:

(with greedy charset)
image
image
Note, that we no longer need to wrap the argument in quotes with these characters.

Fixes

Fixes #103
Fixes #44

Copy link

@0x000006 0x000006 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good to me.

Fortern added a commit to Fortern/brigadier that referenced this pull request Aug 12, 2024
Copy link

@StillLutto StillLutto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, please accept this PR. This would be one of the most, if not the most, useful things for plugin developers using commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants