Interface CustomAdvancement.Builder
- Enclosing interface:
CustomAdvancement
CustomAdvancement.-
Method Summary
Modifier and TypeMethodDescriptionbuildAndBindTo(CustomAdvancement parent) Builds this advancement and binds it to a specifiedCustomAdvancementparent.default CustomAdvancementBuilds this advancement and binds it to the root custom advancement in a specified tab.default CustomAdvancementbuildAndBindToBukkit(String key, org.bukkit.plugin.Plugin plugin) Builds this advancement and binds it to a BukkitAdvancementusing aStringkey.default CustomAdvancementbuildAndBindToBukkit(org.bukkit.advancement.Advancement advancement, org.bukkit.plugin.Plugin plugin) Builds this advancement and binds it to a BukkitAdvancementinstance.buildAndBindToBukkit(org.bukkit.NamespacedKey key, org.bukkit.plugin.Plugin plugin) Builds this advancement and binds it to a BukkitAdvancementusing aNamespacedKey.default CustomAdvancement.BuilderDeprecated.display(CustomAdvancementDisplay display) Sets the display properties of the advancement.default CustomAdvancement.Builderdisplay(CustomAdvancementDisplay.Builder builder) Builds the display properties for the advancement before setting them.default <T extends org.bukkit.event.Event>
CustomAdvancement.Builderon(Class<T> eventClass, BiConsumer<T, CustomAdvancement> handler) Adds an event handler for this advancement with default normal priority (EventPriority.NORMAL).<T extends org.bukkit.event.Event>
CustomAdvancement.Builderon(Class<T> eventClass, org.bukkit.event.EventPriority priority, BiConsumer<T, CustomAdvancement> handler) Adds an event handler for this advancement.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).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.default CustomAdvancement.Builderrequirements(String first, String... other) Sets the requirements for this advancement, where each provided criterion forms its own group.requirements(Set<Set<String>> requirements) Sets the requirements for this advancement with custom groupings.rewards(CustomAdvancementRewards rewards) Sets the rewards for the advancement.default CustomAdvancement.Builderrewards(CustomAdvancementRewards.Builder builder) Builds the rewards for the advancement before setting them.
-
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.in favour of usingrequirements(String, String...), criteria are now automatically derived from requirementsSets 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- aSetof 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
Sets the requirements for this advancement with custom groupings.The format and behavior of requirements are explained in detail in
CustomAdvancement.requirements(). Each innerSetrepresents 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- aSetof 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
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 groupother- 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 topriority- the priority of the event handlerhandler- 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 tohandler- 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
Builds this advancement and binds it to a specifiedCustomAdvancementparent.- Parameters:
parent- the parent custom advancement- Returns:
- the built custom advancement
-
buildAndBindTo
Builds this advancement and binds it to the root custom advancement in a specified tab.- Parameters:
tab- theCustomAdvancementTabwhere 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 BukkitAdvancementinstance.- Parameters:
advancement- the parent Bukkit advancementplugin- 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 BukkitAdvancementusing aStringkey.- Parameters:
key- the string key of the parent advancementplugin- the plugin associated with the advancement- Returns:
- the configured custom advancement
- Throws:
NullPointerException- if the key pattern is invalid- See Also:
-
buildAndBindToBukkit
CustomAdvancement buildAndBindToBukkit(org.bukkit.NamespacedKey key, org.bukkit.plugin.Plugin plugin) Builds this advancement and binds it to a BukkitAdvancementusing aNamespacedKey.- Parameters:
key- the key of the parent advancementplugin- the plugin associated with the advancement- Returns:
- the built custom advancement
-
requirements(String, String...), criteria are now automatically derived from requirements