Interface Expansion.Builder

All Superinterfaces:
AbstractBuilder<Expansion>
Enclosing interface:
Expansion

@NullMarked public static interface Expansion.Builder extends AbstractBuilder<Expansion>
Expansion Builder

Example use:

  Expansion.Builder builder = Expansion.builder("player");
  builder
      // Thanks to this filter, a cast can be performed without the probability of a ClassCastException
      .filter(Player.class)
      .resolver("name", (audience, queue, ctx) -> Tag.selfClosingInserting(Component.text(((Player)audience).getUsername())));
  Expansion expansion = builder.build();
 
then use it:
  Player player = event.getPlayer();
  TagResolver resolver = expansion.resolver(player);
  Component messageReplaced = MiniMessage.deserialize(String, resolver);
 
Since:
1.0.0
  • Method Details

    • audiencePlaceholder

      <A extends Audience> Expansion.Builder audiencePlaceholder(@Nullable @Nullable Class<A> targetClass, String key, AudienceTagResolver<A> audiencePlaceholder)
      Adds an audience placeholder

      This type of Placeholder depends on a specific audience to obtain its values

      The content of this Placeholder is cached and can mutate depending on when it is invoked

      Type Parameters:
      A - the type of audience that this placeholder supports, must be the same as targetClass
      Parameters:
      targetClass - the target class
      key - the placeholder key, cannot be an empty or black string
      audiencePlaceholder - the single placeholder
      Returns:
      the Expansion.Builder itself
      Since:
      1.0.0
    • audiencePlaceholder

      default Expansion.Builder audiencePlaceholder(String key, AudienceTagResolver<Audience> audiencePlaceholder)
      Adds an audience placeholder

      This type of Placeholder depends on a specific audience to obtain its values

      The content of this Placeholder is cached and can mutate depending on when it is invoked

      Parameters:
      key - the placeholder key, cannot be an empty or black string
      audiencePlaceholder - the single placeholder
      Returns:
      the Expansion.Builder itself
      Since:
      3.0.0
    • relationalPlaceholder

      <A extends Audience> Expansion.Builder relationalPlaceholder(@Nullable @Nullable Class<A> targetClass, String key, RelationalTagResolver<A> relationalPlaceholder)
      Adds a Relational Placeholder based on two audiences

      This type of placeholder allows you to create components based on a 2-audiences relationship, one is the one on which the placeholder is based and the other is the one on which the placeholder is displayed.

      The content of this Placeholder is cached and can mutate depending on when it is invoked

      Type Parameters:
      A - the type of audience that this placeholder supports, must be the same as targetClass
      Parameters:
      targetClass - the target class
      key - the placeholder key, cannot be an empty or black string
      relationalPlaceholder - the relational placeholder
      Returns:
      the Expansion.Builder itself
      Since:
      3.0.0
    • relationalPlaceholder

      default Expansion.Builder relationalPlaceholder(String key, RelationalTagResolver<Audience> relationalResolver)
      Adds a Relational Placeholder based on two audiences

      This type of placeholder allows you to create components based on a 2-audiences relationship, one is the one on which the placeholder is based and the other is the one on which the placeholder is displayed.

      The content of this Placeholder is cached and can mutate depending on when it is invoked

      Parameters:
      key - the placeholder key, cannot be an empty or black string
      relationalResolver - the relational placeholder
      Returns:
      the Expansion.Builder itself
      Since:
      3.0.0
    • globalPlaceholder

      Expansion.Builder globalPlaceholder(String key, GlobalTagResolver resolver)
      Adds a global placeholder

      The content of this Placeholder is cached and can mutate depending on when it is invoked

      Parameters:
      key - the placeholder key, cannot be an empty or black string
      resolver - the function
      Returns:
      the Expansion.Builder itself
      Since:
      3.0.0
    • globalPlaceholder

      default Expansion.Builder globalPlaceholder(String key, Tag tag)
      Adds a global placeholder

      This placeholder is not cached and is immutable

      Parameters:
      key - the placeholder key, cannot be an empty or black string
      tag - the tag of this placeholder
      Returns:
      the Expansion.Builder itself
      Since:
      1.1.0
    • author

      @Contract("_ -> this") @NotNull @NotNull Expansion.Builder author(@Nullable @Nullable String author)
      Sets the author of this expansion
      Parameters:
      author - the author of this expansion
      Returns:
      the Expansion.Builder itself
      Since:
      2.3.0
    • version

      @Contract("_ -> this") @NotNull @NotNull Expansion.Builder version(@Nullable @Nullable String version)
      Sets the version of this expansion
      Parameters:
      version - the version of this expansion
      Returns:
      the Expansion.Builder itself
      Since:
      2.3.0