Interface Expansion


@NullMarked public sealed interface Expansion
Expansion that contains placeholders

Usage Example:

  Player player = event.getPlayer();
  Expansion.Builder builder = Expansion.builder("player")
      .resolver(Player.class, "name", (p, queue, ctx) -> Tag.selfClosingInserting(Component.text(p.getUsername()))
      .build();
  Expansion expansion = builder.build();
  // You can also call the register() method to register
  // the Expansion in the MiniPlaceholders global Extensions and
  // use it in MiniPlaceholders.audiencePlaceholders() e.g.
  TagResolver resolver = expansion.resolver();
  player.sendMessage(MiniMessage.miniMessage().deserialize("Hello <luckperms_prefix> <player_name>", player, resolver));
 
Since:
1.0.0
  • Method Details

    • name

      String name()
      Get the expansion name
      Returns:
      the expansion name
      Since:
      1.0.0
    • author

      @Nullable @Nullable String author()
      Get the author of this expansion
      Returns:
      the author or null
      Since:
      2.3.0
    • version

      @Nullable @Nullable String version()
      Get the version of this expansion
      Returns:
      the version or null
      Since:
      2.3.0
    • audiencePlaceholders

      TagResolver audiencePlaceholders()
      Get the TagResolver of an Audience
      Returns:
      A TagResolver with variable placeholders of an Audience
      Since:
      1.0.0
    • relationalPlaceholders

      TagResolver relationalPlaceholders()
      Get the relational placeholders based on two audiences

      The resulting TagResolver will give results according to the 2 Audience provided and when called at any time will retrieve the required values

      Returns:
      A TagResolver with variable placeholders between 2 Audiences
      Since:
      1.0.0
    • globalPlaceholders

      TagResolver globalPlaceholders()
      Get global placeholders
      Returns:
      the global placeholders
      Since:
      1.0.0
    • register

      void register()
      Register this expansion
      Throws:
      IllegalStateException - if the expansion you are trying to register is already registered
      Since:
      1.0.0
      See Also:
    • unregister

      void unregister()
      Unregisters this expansion
      Throws:
      IllegalStateException - if the expansion you are trying to unregister is not registered
      Since:
      2.1.0
      See Also:
    • registered

      boolean registered()
      Get the registration status of this expansion
      Returns:
      true if the expansion is registered, otherwise false
      Since:
      2.1.0
    • registeredAudiencePlaceholders

      Collection<AudiencePlaceholder<?>> registeredAudiencePlaceholders()
      Get the registered audience placeholders
      Returns:
      registered audience placeholders
    • registeredRelationalPlaceholders

      Collection<RelationalPlaceholder<?>> registeredRelationalPlaceholders()
      Get the registered relational placeholders
      Returns:
      registered relational placeholders
    • audiencePlaceholderByName

      @Nullable @Nullable AudiencePlaceholder<?> audiencePlaceholderByName(String name)
      Get an Audience Placeholder by name
      
            Expansion expansion = MiniPlaceholders.expansionByName("player")
            AudiencePlaceholder<?> placeholder = expansion.audiencePlaceholderByName("name");
       
      Parameters:
      name - the name of the placeholder to search
      Returns:
      the desired placeholder or null
    • relationalPlaceholderByName

      @Nullable @Nullable RelationalPlaceholder<?> relationalPlaceholderByName(String name)
      Get a Relational Placeholder by name
      
            Expansion expansion = MiniPlaceholders.expansionByName("expansion")
            RelationalPlaceholder<?> placeholder = expansion.relationalPlaceholderByName("placeholder");
       
      Parameters:
      name - the name of the placeholder to search
      Returns:
      the desired placeholder or null
      API Note:
      The name of a relational placeholder does not contain the prefix “rel”, just the name assigned when it was created
    • globalPlaceholderByName

      @Nullable @Nullable GlobalPlaceholder globalPlaceholderByName(String name)
      Get a Global Placeholder by name
      
            Expansion expansion = MiniPlaceholders.expansionByName("player")
            GlobalPlaceholder placeholder = expansion.globalPlaceholderByName("name");
       
      Parameters:
      name - the name of the placeholder to search
      Returns:
      the desired placeholder or null
    • hasAudiencePlaceholder

      default boolean hasAudiencePlaceholder(String name)
      Checks whether an audience placeholder with the specified name has been registered in this expansion.
      Parameters:
      name - the name of the placeholder to check
      Returns:
      true if the placeholder is registered, else false
    • hasRelationalPlaceholder

      default boolean hasRelationalPlaceholder(String name)
      Checks whether a relational placeholder with the specified name has been registered in this expansion.
      Parameters:
      name - the name of the placeholder to check
      Returns:
      true if the placeholder is registered, else false
    • hasGlobalPlaceholder

      default boolean hasGlobalPlaceholder(String name)
      Checks whether a global placeholder with the specified name has been registered in this expansion.
      Parameters:
      name - the name of the placeholder to check
      Returns:
      true if the placeholder is registered, else false
    • placeholdersByType

      TagResolver placeholdersByType(PlaceholderType type)
      Get a TagResolver that contains all placeholders of a specific type in this expansion.
      Parameters:
      type - the desired type
      Returns:
      a TagResolver containing all placeholder of a specific type
    • builder

      static Expansion.Builder builder(String name)
      Creates a new Expansion Builder
      Parameters:
      name - the expansion name
      Returns:
      a new expansion builder
      Since:
      1.0.0
    • shortToString

      @Internal default String shortToString()
      Get a shorter ToString with the details of this expansion.
      Returns:
      a shorter ToString