Klasse AdvancementRegisterBuilder<E extends org.bukkit.event.Event>

java.lang.Object
io.github.lambdaphoenix.advancementLib.AdvancementRegisterBuilder<E>
Typparameter:
E - the event type

public class AdvancementRegisterBuilder<E extends org.bukkit.event.Event> extends Object
Fluent Builder for registering custom advancements in your plugin.

Allows you to specify all the details for your advancement, including the event, conditions, progress targets, and how criteria are granted.

Required parameters:

  • advancementKey (unique string identifier)
  • eventType (class of the Bukkit event)
These must be set before calling build().

Optional parameters:

  • condition - predicate for event acceptance (defaults to always true)
  • playerExtractor - function to extract the player from the event (defaults to PlayerExtractor.getDefaultPlayerExtractor(Class, Logger) if available)
  • increment - function to determine progress increment (if null, defaults to 1 per event; otherwise, uses the provided function)
  • targetValue - required progress to complete (default: 1, must be at least 1)
  • grantMode - how the advancement is granted (default: GrantMode.ALL_AT_ONCE)

Note: The PlayerExtractor utility provides default extractors for common Bukkit events. For custom events, you may supply your own extractor.

Seit:
0.2.0
Version:
0.3.1
Autor:
lambdaphoenix
Siehe auch:
  • Konstruktordetails

    • AdvancementRegisterBuilder

      public AdvancementRegisterBuilder(AdvancementAPI api)
      Start building a new advancement.
      Parameter:
      api - the AdvancementAPI instance; must not be null
      Löst aus:
      NullPointerException - if api is null
      Seit:
      0.2.0
      Siehe auch:
    • AdvancementRegisterBuilder

      public AdvancementRegisterBuilder(AdvancementAPI api, String advancementKey)
      Start building a new advancement with a specific key.
      Parameter:
      api - the AdvancementAPI instance; must not be null
      advancementKey - the unique name for this advancement; must not be null
      Seit:
      0.2.0
      Siehe auch:
    • AdvancementRegisterBuilder

      public AdvancementRegisterBuilder(AdvancementAPI api, String advancementKey, Class<E> eventType)
      Start building a new advancement with a specific key and event type.
      Parameter:
      api - the AdvancementAPI instance; must not be null
      advancementKey - the unique name for this advancement; must not be null
      eventType - the event type that triggers this advancement; must not be null
      Seit:
      0.2.0
      Siehe auch:
  • Methodendetails

    • advancementKey

      public AdvancementRegisterBuilder<E> advancementKey(String advancementKey)
      Sets the unique identifier for this advancement.
      Parameter:
      advancementKey - the advancement name; must not be null
      Gibt zurück:
      this builder
      Löst aus:
      NullPointerException - if advancementKey is null
      Seit:
      0.2.0
    • eventType

      public AdvancementRegisterBuilder<E> eventType(Class<E> eventType)
      Sets the event type that triggers this advancement.
      Parameter:
      eventType - the event class; must not be null
      Gibt zurück:
      this builder
      Löst aus:
      NullPointerException - if eventType is null
      Seit:
      0.2.0
      Siehe auch:
      • Event
    • condition

      public AdvancementRegisterBuilder<E> condition(BiPredicate<org.bukkit.entity.Player,E> condition)
      Sets the condition that must be true for the advancement to progress.

      If not set, defaults to always true.

      Parameter:
      condition - a predicate (player, event) -> true if this event should count
      Gibt zurück:
      this builder
      Seit:
      0.2.0
      Siehe auch:
    • targetValue

      public AdvancementRegisterBuilder<E> targetValue(int targetValue)
      Sets how many times the event must occur before the advancement is granted.

      Must be at least 1. Default is 1.

      Parameter:
      targetValue - the number of times the event must occur
      Gibt zurück:
      this builder
      Seit:
      0.2.0
    • playerExtractor

      public AdvancementRegisterBuilder<E> playerExtractor(Function<E,org.bukkit.entity.Player> playerExtractor)
      Sets a custom function to extract the player from the event.

      If not set, a default extractor will be used if available for the event type (see PlayerExtractor.getDefaultPlayerExtractor(Class, Logger)).

      Parameter:
      playerExtractor - function to extract the player from the event
      Gibt zurück:
      this builder
      Seit:
      0.2.0
      Siehe auch:
    • grantMode

      public AdvancementRegisterBuilder<E> grantMode(GrantMode grantMode)
      Sets how criteria are granted to the player

      Defaults to GrantMode.ALL_AT_ONCE.

      Parameter:
      grantMode - the grant mode; must not be null
      Gibt zurück:
      this builder
      Löst aus:
      NullPointerException - if grantMode is null
      Seit:
      0.2.0
      Siehe auch:
    • increment

      public AdvancementRegisterBuilder<E> increment(ToIntFunction<E> increment)
      Sets how much progress each event should add.

      If not set, each event increases progress by 1.

      Parameter:
      increment - function to determine progress increment
      Gibt zurück:
      this builder
      Seit:
      0.2.0
      Siehe auch:
    • build

      public void build()
      Registers the advancement with the specified configuration.

      You must set both advancementKey and eventType before calling this.

      Löst aus:
      IllegalArgumentException - if required fields are missing or invalid
      Seit:
      0.2.0
      Siehe auch:
      • AdvancementAPI.registerAdvancement(String, Class, BiPredicate, int, Function, GrantMode, ToIntFunction)