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

      CustomAdvancement.Builder criteria(Set<String> criteria)
      Sets the criteria for this advancement.

      This method automatically updates the requirements so that each criterion forms its own group. If this behavior is not desired, a subsequent call to requirements(Set) should be made to override the default grouping.

      Default: Set.of("dummy")

      Parameters:
      criteria - a Set of criteria names
      Returns:
      this builder instance for chaining
    • requirements

      CustomAdvancement.Builder requirements(Set<Set<String>> requirements)
      Sets the requirements for this advancement by grouping criteria.

      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.

      A call to this method must be made after criteria(Set), as calling criteria(Set) afterward will overwrite the requirements.

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

      Parameters:
      requirements - a set of grouped criteria requirements
      Returns:
      this builder instance for chaining
      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
    • 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