-
-
Notifications
You must be signed in to change notification settings - Fork 404
Commands rework - Brigadier backend #8111
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
base: dev/feature
Are you sure you want to change the base?
Conversation
…hin a section node
…le entry container
I likely won't review this but I'm more concerned about how this will work, since I'm not a huge fan of the implications this makes. How exactly are you intending to handle multiple arguments and their suggestions? If anything I would prefer them handled in a way similar to I also don't see anything like sub arguments/commands of sub commands |
Thanks for the feedback, let me clear up some things. :)
Correct, if you structure the command as command /foo <first: word> <second: word> <third: word>:
suggestions:
# something the suggestions will apply only for the last node (argument command /foo:
suggestions:
# suggestions for first
subcommand <first: word>:
suggestions:
# suggestions for second
subcommand <second: word>:
suggestions:
# suggestions for third
subcommand <third: word>: But it is good to note that the command nodes themselves have own suggestion logic, for command such as command /foo:
subcommand bar
subcommand world both
Yes, MessageComponent -> SpigotComponent -> PaperComponent -> Suggestion. Suggestions can only be plain text with a component tooltip, I felt like using existing MessageComponent fits well here. Possible improvement would be to convert MessageComponent directly to Suggestion, but I think introducing Suggestion as a separate type is too specific.
Subcommands can already have other subcommands if that is the question, SubCommandEntryData can be nested. |
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.
looks like a great start!
I'm sure it's in progress but just a reminder to add a bunch more javadocs to stuff, too.
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.
Any reason these files are still in ch/njo/skript?
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.
I wanted to keep the platform implementation separate and thought putting it next to the current command system was better choice. I will change it to the org/skriptlang/skript package then
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.
Yeah you can just make a bukkit/paper package for it (like the previous pr did iirc)
|
||
static { | ||
Skript.registerArgumentType(DefaultArgumentTypes.String.class, | ||
"[single] (word|string)", "[quotable|quoted] string", "greedy string"); |
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.
"[single] (word|string)", "[quotable|quoted] string", "greedy string"); | |
"[single] (word|string)", "(quotable|quoted) string", "greedy string"); |
|
||
static { | ||
Skript.registerArgumentType(DefaultArgumentTypes.Integer.class, | ||
"integer [from %-integer% [to %-integer%]]"); |
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.
i'd like to see some more friendly versions like integer greater than x
or integer less than or equal to y
It's also unsafe to get the values of expressions without events, so these would need to be literals or parsed/evaluated with a proper event.
I get why you prefer this over validation sections and it does seem more convenient, but I feel it also adds unnecessary duplication when we could instead leverage existing syntaxes and give users more control using validation sections. I've mixed feelings on it.
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.
i'd like to see some more friendly versions like
integer greater than x
orinteger less than or equal to y
I agree, the syntax was more for demonstration; I will change this later
It's also unsafe to get the values of expressions without events, so these would need to be literals or parsed/evaluated with a proper event.
The argument parser does not parse expressions, only literals. I assume that should be safe, but correct me if I am wrong.
I get why you prefer this over validation sections and it does seem more convenient, but I feel it also adds unnecessary duplication when we could instead leverage existing syntaxes and give users more control using validation sections. I've mixed feelings on it.
One of the strong points for this was the integration with brigadier (e.g., client can predict when the user input is outside the integer range before the command is sent). I suppose we could have a mix of both, but I am really for the current syntax and I am not sure if having both wouldn't be too bloated.
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.
The argument parser does not parse expressions, only literals. I assume that should be safe, but correct me if I am wrong.
ok yeah if it's only literals you should cast it to literal and just use get()
instead of get(Event)
imo
And I'm fine with having a mix of both, but validation sections/similar ideas don't need to be a priority, since users can just write them themselves in the trigger.
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.
Actually, for future-proofing for contextless expr, just evaluate with ContextlessEvent.get(), don't cast
* @param patterns patterns | ||
* @param <E> argument type | ||
*/ | ||
public static <E extends ArgumentTypeElement<?>> void registerArgumentType(Class<E> argumentClass, String... patterns) { |
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.
i'm not really sure about this being in the Skript class.
This is a continuation of #7032 from the ground up. x)
Problem
The current Skript command system has several drawbacks for both Skript users and maintainers. I think the biggest are:
hello <string> <number>
, where the inputhello foo 1 2
is considered valid. I also see this implementation as a maintenance burden.Solution
The solution is to switch to Brigadier as the command backend.
The new implementation is now fully separate from the existing command system, mainly because of the many changes between the two. It is very unlikely this will change. My aim is to integrate most of the features from the old command system, deprecate it, and fully remove it later. This will and should take a lot of time.
Not using Brigadier as a backend would take a lot of extra effort for what I believe is no extra gain, why reinvent the wheel if we don't have to..
Planned Syntax:
Existing Work:
integer from %integer% to %integer%
or simple ones likeword
. Right now, you cannot simply use different class infos as arguments, but I plan on supporting this later. I prefer this approach over a validation section because:The current work is divided into three different packages:
org.skriptlang.skript.lang.command
- general classes related to syntax, parsing, and the new command API.org.skriptlang.skript.brigadier
- classes that expand on the Brigadier library.ch.njol.skript.command.brigadier
- platform-specific (Paper) implementation of the new command API.Work to be Done:
What will almost surely be lost compared to the old command system:
Testing Completed
Only local testing has been performed for now. I need to spend more time with this PR before I can start writing proper tests.
This PR is meant for Paper servers running on 1.21 and above, that's why the existing tests on lower versions might fail.
Completes: none
Related: #7032