-
-
Notifications
You must be signed in to change notification settings - Fork 342
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
Parameters for user selectors, user or target, and multiple users #2389
Comments
As intended. Parameter.firstOf(Parameter.player()..., Parameter.user()) and you handle the case where you have a player, vs the case where you have a UUID.
Not quite - though that's why the User methods return a UUID. In the vast majority of cases, you don't need a As I said above though,
They are intended to be used publically - if it wasn't destined to exist in the API then it wouldn't be there! I just never added it to the |
I did try using The command should have the usage private static final Parameter.Value<ServerPlayer> PLAYER = Parameter.player().key("player").build();
private static final Parameter.Value<UUID> USER = Parameter.user().key("user").build();
public static Command.Parameterized COMMAND = Command.builder()
.permission("cratecrate.command.key.give.base")
.addParameter(Parameter.firstOf(PLAYER, USER))
.addParameter(Parameter.choices(Key.class, Config.KEYS::get, Config.KEYS::keySet).key("key").build())
.addParameter(Parameter.rangedInteger(1, Integer.MAX_VALUE).key("quantity").build())
.executor(Give::execute)
.build(); |
Welcome to Brigadier! On the (player | user) thing - there is little we can do about it, unfortuantely - we have no control over the client, we just send the nodes and the client handles the hints like that. Coupled with this PR not yet being merged, we're kind of stuck with what we can do (redirects would make this nicer...).
|
This is a straightforward solution that only supports names and waits for the user to load. More complex options like selectors, target defaults, and multiple users is partially blocked by SpongePowered/SpongeAPI#2389.
I fixed the issue in your last comment about optional parameters - inverted boolean. As for everything else - I don't think there is really anything I want to do. You mentioned in your commit for your plugin about selectors being partially blocked by this issue - but it's not really, as I say, selectors only work on If you want to collapse this into a single parameter, I think my answer to that is "do it yourself", but I would strongly advise using the parameters as set and do minimal additional logic in the parsers, preferring the executor whenever possible. We're trying to gear the system for performance, you don't want to be pausing the world to retrieve a user during parse time (which could be called multiple times for command completions -- you probably don't want that to happen). |
The
Parameter
class contains helpers forplayer()
(which supports selectors) andplayerOrTarget()
, but not similar methods for users. There is also aResourceKeyedValueParameters.MANY_GAME_PROFILES
parameter (as well as one forMANY_PLAYERS
), but these do not have helpers inParameter
so I am unsure if they are intended to be used publicly.I believe what's happening here is that because users must be loaded, it is more performant to start with the player related methods and then fall back to users with some type of
Parameter.firstOf(...)
approach, though how exactly that's done I'm not sure. Still, it would be helpful to have some methods inParameter
for these situations if possible.The text was updated successfully, but these errors were encountered: