Class PositionArguments

java.lang.Object
fr.robie.machineengine.api.paper.PositionArguments

public final class PositionArguments extends Object
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.

  • 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()
    • 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), after positionArgument().
    • 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: its positionArgument() and worldArgument(), else fallback for 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

      @Nullable public static @Nullable org.bukkit.World world(@NotNull @NotNull String name)
      A world by name (world) or key (minecraft:overworld).