Interface CustomAdvancement

All Superinterfaces:
Keyed, net.kyori.adventure.key.Keyed

@NullMarked public sealed interface CustomAdvancement extends Keyed
Represents a custom advancement.

A custom advancement defines a unique milestone or task for players to achieve.

  • Method Details

    • advancement

      static CustomAdvancement.Builder advancement(org.bukkit.NamespacedKey key)
      Creates a new builder for a CustomAdvancement using the given NamespacedKey.
      Parameters:
      key - the namespaced key of the advancement
      Returns:
      the builder to configure and build the advancement
      See Also:
      • NamespacedKey(Plugin, String)
    • display

      Gets the display properties of the custom advancement.
      Returns:
      the advancement's display settings
      See Also:
    • rewards

      Gets the rewards granted upon completing the advancement.
      Returns:
      the advancement's rewards
      See Also:
    • criteria

      @Unmodifiable Set<String> criteria()
      Gets the Set of criteria.

      Which criteria must be met to complete this advancement is defined in the requirements().

      Returns:
      an unmodifiable Set of criteria
      See Also:
    • requirements

      @Unmodifiable Set<Set<String>> requirements()
      Gets the Set of criteria groups that define the requirements for advancement completion.

      Some advancements require players to fulfill multiple groups of criteria, where completing any criterion within a group satisfies that group. The advancement is completed when all groups have been satisfied.

      Example:
      
       Set.of(
           Set.of("diamond_axe", "diamond_sword"),
           Set.of("iron_shovel", "iron_hoe")
       )
       
      This means the advancement consists of two groups. To complete the first group, the player must obtain either the "diamond_axe" or the "diamond_sword" criterion. To complete the second group, they must obtain either the "iron_shovel" or the "iron_hoe" criterion.
      Returns:
      an unmodifiable Set of requirement groups, where each group is a Set of criteria
    • progress

      org.bukkit.advancement.AdvancementProgress progress(org.bukkit.entity.Player player)
      Gets the AdvancementProgress associated with the given player.
      Parameters:
      player - the player for whom the progress is fetched
      Returns:
      the player's advancement progress
      See Also:
      • AdvancementProgress
    • tab

      Gets the CustomAdvancementTab where this advancement is displayed.
      Returns:
      the custom advancement tab this advancement belongs to
      Throws:
      UnsupportedOperationException - if this advancement does not belong to a custom tab (if this advancement was created using CustomAdvancement.Builder.buildAndBindToBukkit(org.bukkit.advancement.Advancement, org.bukkit.plugin.Plugin))
      See Also:
    • parent

      Gets the parent CustomAdvancement.
      Returns:
      the parent advancement
      Throws:
      UnsupportedOperationException - if this advancement is a root advancement or it does not have a CustomAdvancement parent
      See Also:
    • parentKey

      org.bukkit.NamespacedKey parentKey()
      Gets the NamespacedKey of the parent advancement.
      Returns:
      The parent advancement's namespaced key.
      Throws:
      UnsupportedOperationException - if this advancement is a root advancement
      See Also:
    • asBukkit

      org.bukkit.advancement.Advancement asBukkit()
      Converts this custom advancement into a Bukkit Advancement instance.
      Returns:
      the corresponding Bukkit advancement
    • isRoot

      boolean isRoot()
      Checks whether this custom advancement is a root advancement.
      Returns:
      true if this advancement is a root advancement, otherwise false.
    • hasCustomParent

      boolean hasCustomParent()
      Checks whether this custom advancement has a CustomAdvancement parent.
      Returns:
      true if this advancement has a parent and it is a CustomAdvancement, otherwise false
    • hasCustomTab

      boolean hasCustomTab()
      Checks whether this custom advancement belongs to a CustomAdvancementTab.
      Returns:
      true if this advancement has a custom advancement tab, otherwise false
    • plugin

      org.bukkit.plugin.Plugin plugin()
      Gets the plugin associated with this custom advancement.
      Returns:
      the plugin that this advancement belongs to