Advancement arguments

An advancement argument suggesting a list of Minecraft advancements

The AdvancementArgument class represents in-game advancements. As expected, the AdvancementArgument can be casted to Bukkit's Advancement class.

Example - Awarding a player an advancement

Say we want to award a player an advancement. First, we need the syntax that our command will use:

/award <player> <advancement>

Since we require a player, we will use the PlayerArgument for this example. Given a player, we can simply get the AdvancementProgress for that player, and then award the criteria required to fully complete the provided advancement.

new CommandAPICommand("award")
    .withArguments(new PlayerArgument("player"))
    .withArguments(new AdvancementArgument("advancement"))
    .executes((sender, args) -> {
        Player target = (Player) args.get("player");
        Advancement advancement = (Advancement) args.get("advancement");
        
        // Award all criteria for the advancement
        AdvancementProgress progress = target.getAdvancementProgress(advancement);
        for (String criteria : advancement.getCriteria()) {
            progress.awardCriteria(criteria);
        }
    })
    .register();
CommandAPICommand("award")
    .withArguments(PlayerArgument("player"))
    .withArguments(AdvancementArgument("advancement"))
    .executes(CommandExecutor { _, args ->
        val target = args["player"] as Player
        val advancement = args["advancement"] as Advancement

        // Award all criteria for the advancement
        val progress = target.getAdvancementProgress(advancement)
        for (criteria in advancement.criteria) {
            progress.awardCriteria(criteria)
        }
    })
    .register()
commandAPICommand("award") {
    playerArgument("player")
    advancementArgument("advancement")
    anyExecutor { _, args ->
        val target = args["player"] as Player
        val advancement = args["advancement"] as Advancement

        // Award all criteria for the advancement
        val progress = target.getAdvancementProgress(advancement)
        for (criteria in advancement.criteria) {
            progress.awardCriteria(criteria)
        }
    }
}