Interface CustomAdvancement.Builder

Enclosing interface:
CustomAdvancement

public static sealed interface CustomAdvancement.Builder
Builder for creating and configuring instances of CustomAdvancement.
  • Method Details

    • display

      Sets the display properties of the advancement.

      Default: CustomAdvancementDisplay.empty()

      Parameters:
      display - the display properties for the advancement
      Returns:
      this builder instance for chaining
      See Also:
    • display

      Builds the display properties for the advancement before setting them.

      Default: CustomAdvancementDisplay.empty()

      Parameters:
      builder - a builder for the display settings
      Returns:
      this builder instance for chaining
    • rewards

      Sets the rewards for the advancement.

      Default: CustomAdvancementRewards.empty()

      Parameters:
      rewards - the rewards for completing the advancement
      Returns:
      this builder instance for chaining
      See Also:
    • rewards

      Builds the rewards for the advancement before setting them.

      Default: CustomAdvancementRewards.empty()

      Parameters:
      builder - a builder for the rewards settings
      Returns:
      this builder instance for chaining
    • criteria

      @Deprecated default CustomAdvancement.Builder criteria(Set<String> criteria)
      Deprecated.
      in favour of using requirements(String, String...), criteria are now automatically derived from requirements
      Sets the criteria for this advancement.

      This method automatically updates the requirements so that each criterion forms its own group.

      Default: Set.of("dummy")

      Parameters:
      criteria - a Set of criteria names
      Returns:
      this builder instance for chaining
      Throws:
      IllegalArgumentException - if no criteria are provided, or if any criterion is empty or contains only whitespace
    • requirements

      CustomAdvancement.Builder requirements(Set<Set<String>> requirements)
      Sets the requirements for this advancement with custom groupings.

      The format and behavior of requirements are explained in detail in CustomAdvancement.requirements(). Each inner Set represents a requirement group, where completing any criterion within a group satisfies that group. The advancement is completed when all groups are satisfied.

      Default: Set.of(Set.of("dummy"))

      Parameters:
      requirements - a Set of grouped criteria requirements
      Returns:
      this builder instance for chaining
      Throws:
      IllegalArgumentException - if no criteria are provided, or if any criterion is empty or contains only whitespace
      See Also:
    • requirements

      default CustomAdvancement.Builder requirements(String first, String... other)
      Sets the requirements for this advancement, where each provided criterion forms its own group.

      This means that all of the specified criteria must be completed in order to unlock the advancement.

      For more advanced configuration with grouped requirements, use requirements(Set).

      Default: "dummy"

      Parameters:
      first - the first criterion, forming its own group
      other - other additional criteria, each forming its own group (optional)
      Returns:
      this builder instance for chaining
      Throws:
      IllegalArgumentException - if any criterion is empty or contains only whitespace
      See Also:
    • on

      <T extends org.bukkit.event.Event> CustomAdvancement.Builder on(Class<T> eventClass, org.bukkit.event.EventPriority priority, BiConsumer<T,CustomAdvancement> handler)
      Adds an event handler for this advancement.
      Type Parameters:
      T - the type of the event
      Parameters:
      eventClass - the event class to listen to
      priority - the priority of the event handler
      handler - the handler executed when the event occurs
      Returns:
      this builder instance for chaining
    • on

      default <T extends org.bukkit.event.Event> CustomAdvancement.Builder on(Class<T> eventClass, BiConsumer<T,CustomAdvancement> handler)
      Adds an event handler for this advancement with default normal priority (EventPriority.NORMAL).
      Type Parameters:
      T - the type of the event
      Parameters:
      eventClass - the event class to listen to
      handler - the handler executed when the event occurs
      Returns:
      this builder instance for chaining
    • onCriterionGranted

      CustomAdvancement.Builder onCriterionGranted(BiConsumer<com.destroystokyo.paper.event.player.PlayerAdvancementCriterionGrantEvent,CustomAdvancement> handler)
      Adds an event handler that fires when a player is granted any criterion of this advancement.

      This event is registered with the priority EventPriority.NORMAL.

      Parameters:
      handler - the handler executed when the event occurs
      Returns:
      this builder instance for chaining
    • onAdvancementCompleted

      CustomAdvancement.Builder onAdvancementCompleted(BiConsumer<com.destroystokyo.paper.event.player.PlayerAdvancementCriterionGrantEvent,CustomAdvancement> handler)
      Adds an event handler that fires when a player completes this advancement (i.e., when they have acquired all required criteria).

      This event is registered with the priority EventPriority.NORMAL.

      Parameters:
      handler - the handler executed when the event occurs
      Returns:
      this builder instance for chaining
    • buildAndBindTo

      CustomAdvancement buildAndBindTo(CustomAdvancement parent)
      Builds this advancement and binds it to a specified CustomAdvancement parent.
      Parameters:
      parent - the parent custom advancement
      Returns:
      the built custom advancement
    • buildAndBindTo

      default CustomAdvancement buildAndBindTo(CustomAdvancementTab tab)
      Builds this advancement and binds it to the root custom advancement in a specified tab.
      Parameters:
      tab - the CustomAdvancementTab where the advancement belongs
      Returns:
      the built custom advancement
    • buildAndBindToBukkit

      default CustomAdvancement buildAndBindToBukkit(org.bukkit.advancement.Advancement advancement, org.bukkit.plugin.Plugin plugin)
      Builds this advancement and binds it to a Bukkit Advancement instance.
      Parameters:
      advancement - the parent Bukkit advancement
      plugin - the plugin associated with the advancement
      Returns:
      the built custom advancement
    • buildAndBindToBukkit

      default CustomAdvancement buildAndBindToBukkit(@KeyPattern String key, org.bukkit.plugin.Plugin plugin)
      Builds this advancement and binds it to a Bukkit Advancement using a String key.
      Parameters:
      key - the string key of the parent advancement
      plugin - the plugin associated with the advancement
      Returns:
      the configured custom advancement
      Throws:
      NullPointerException - if the key pattern is invalid
      See Also:
      • NamespacedKey
    • buildAndBindToBukkit

      CustomAdvancement buildAndBindToBukkit(org.bukkit.NamespacedKey key, org.bukkit.plugin.Plugin plugin)
      Builds this advancement and binds it to a Bukkit Advancement using a NamespacedKey.
      Parameters:
      key - the key of the parent advancement
      plugin - the plugin associated with the advancement
      Returns:
      the built custom advancement