Tag arguments Location


#1

[Google Trad]
Hello,
When I type an order I would like that with the tab key it adds directly the position of the player, currently I do like this:

@Override
public CommandSpec getSpec() {
return CommandSpec.builder()
.permission(“admintoolv2.coffre.create”)
.description(Text.of(“Crée un coffre”))
.arguments(
GenericArguments.optional(GenericArguments.vector3d(Text.of(“Position”)))
)
.executor(this)
.build();
}

I thought I would do it, but it does not work:

@Override
public CommandSpec getSpec() {
return CommandSpec.builder()
.permission(“admintoolv2.coffre.create”)
.description(Text.of(“Crée un coffre”))
.arguments(
GenericArguments.optional(GenericArguments.vector3d(Text.of(“Position”)))
)
.executor((src, args) -> {
Optional player = args.getOne(“player”); // Get the “player” argument, it may not exist so Optional.empty() may be returned
if(player.isPresent()) {
return player.get().getLocation().getPosition();
}
// Do stuff here
return CommandResult.empty();
})
.build();
}


[Français]
Bonjour,
Quand je tape une commande j’aimerais qu’avec la touche tab ça ajoute directement la position du joueur, actuellement je fais comme ça:

@Override
public CommandSpec getSpec() {
return CommandSpec.builder()
.permission(“admintoolv2.coffre.create”)
.description(Text.of(“Crée un coffre”))
.arguments(
GenericArguments.optional(GenericArguments.vector3d(Text.of(“Position”)))
)
.executor(this)
.build();
}

Je pensais faire comme ça, mais ça ne fonctionne pas:

@Override
public CommandSpec getSpec() {
return CommandSpec.builder()
.permission(“admintoolv2.coffre.create”)
.description(Text.of(“Crée un coffre”))
.arguments(
GenericArguments.optional(GenericArguments.vector3d(Text.of(“Position”)))
)
.executor((src, args) -> {
Optional player = args.getOne(“player”); // Get the “player” argument, it may not exist so Optional.empty() may be returned
if(player.isPresent()) {
return player.get().getLocation().getPosition();
}
// Do stuff here
return CommandResult.empty();
})
.build();
}


#2

Personally I would create your own version of the argument CommandSpec that has the tab autocomplete checking if the command sender is Locatable (a player or command block if it was originally a command sender) then grab the location.

Its how I will be doing it in my MinigameLoader plugin.


#3

[Google Trad]
I do not speak English

I do like that eventually:

code

CommandSpec.builder()
.permission(“admintoolv2.coffre.create”)
.description(Text.of(“Crée un coffre”))
.arguments(
GenericArguments.onlyOne(GenericArguments.string(Text.of(“Nom du coffre”))),
GenericArguments.optional(GenericArguments.vector3d(Text.of(“Position X Y Z”)))
)
.executor(this)
.build();

Too bad, I wanted to autocomplete the command with that position

[Français]
Je fais comme ça finalement:

code

CommandSpec.builder()
.permission(“admintoolv2.coffre.create”)
.description(Text.of(“Crée un coffre”))
.arguments(
GenericArguments.onlyOne(GenericArguments.string(Text.of(“Nom du coffre”))),
GenericArguments.optional(GenericArguments.vector3d(Text.of(“Position X Y Z”)))
)
.executor(this)
.build();

Dommage, je voulais auto-completer la commande avec ça position


#4

[Google Trad]
When I put this code the world is self-completed:
GenericArguments.onlyOne(GenericArguments.world(Text.of(“Monde”))),
and:
WorldProperties world = args.getOne(“Monde”).get();

How do I do for player coordinates? because if I use this code:
GenericArguments.optional(GenericArguments.vector3d(Text.of(“Position X Y Z”)))
He does not do it.

[Français]
Quand je mets ce code les monde sont auto-complété:
GenericArguments.onlyOne(GenericArguments.world(Text.of(“Monde”))),
et:
WorldProperties world = args.getOne(“Monde”).get();

Comment je fais pour les coordonnés du player ? car si j’utilise ce code:
GenericArguments.optional(GenericArguments.vector3d(Text.of(“Position X Y Z”)))
Il ne le fait pas.