Class PositionArguments
java.lang.Object
fr.robie.machineengine.api.paper.PositionArguments
Optional
[<x y z>] [<world>] arguments that default to the player running the command.
Coordinates accept ~ (relative to the executor); the world is a name (world) or a
key (minecraft:overworld) and defaults to the executor's world. Without coordinates, a
player uses the PositionArguments.Default position; the console must give them.
Brigadier types only, so any command library can use it (D35): add positionArgument()
then worldArgument() as optional arguments and call resolve(CommandContext, PositionArguments.Default) when the command runs.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhat a player's position defaults to when no coordinates are given.static final recordA command position: a world and block coordinates. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull com.mojang.brigadier.builder.RequiredArgumentBuilder<io.papermc.paper.command.brigadier.CommandSourceStack, io.papermc.paper.command.brigadier.argument.resolvers.BlockPositionResolver> The<x y z>argument;resolve(CommandContext, PositionArguments.Default)reads it.static @Nullable PositionArguments.Positionresolve(@NotNull com.mojang.brigadier.context.CommandContext<io.papermc.paper.command.brigadier.CommandSourceStack> context, @NotNull PositionArguments.Default fallback) The position a command was run for: itspositionArgument()andworldArgument(), elsefallbackfor a player.static @Nullable org.bukkit.WorldA world by name (world) or key (minecraft:overworld).static @NotNull com.mojang.brigadier.builder.RequiredArgumentBuilder<io.papermc.paper.command.brigadier.CommandSourceStack, String> The<world>argument (rest of the line, world names suggested), afterpositionArgument().
-
Method Details
-
positionArgument
@NotNull public static @NotNull com.mojang.brigadier.builder.RequiredArgumentBuilder<io.papermc.paper.command.brigadier.CommandSourceStack, io.papermc.paper.command.brigadier.argument.resolvers.BlockPositionResolver> positionArgument()The<x y z>argument;resolve(CommandContext, PositionArguments.Default)reads it. -
worldArgument
@NotNull public static @NotNull com.mojang.brigadier.builder.RequiredArgumentBuilder<io.papermc.paper.command.brigadier.CommandSourceStack, String> worldArgument()The<world>argument (rest of the line, world names suggested), afterpositionArgument(). -
resolve
@Nullable public static @Nullable PositionArguments.Position resolve(@NotNull @NotNull com.mojang.brigadier.context.CommandContext<io.papermc.paper.command.brigadier.CommandSourceStack> context, @NotNull @NotNull PositionArguments.Default fallback) The position a command was run for: itspositionArgument()andworldArgument(), elsefallbackfor a player.- Returns:
- the position, or null after telling the sender what is wrong (console without coordinates, unknown world, nothing looked at, invalid coordinates)
-
world
A world by name (world) or key (minecraft:overworld).
-