Class MiniPlaceholders

java.lang.Object
io.github.miniplaceholders.api.MiniPlaceholders

public final class MiniPlaceholders extends Object
MiniPlaceholders, a component-based placeholders API.

This class allows you to obtain the TagResolver that other plugins provide based on single Audience, 2-audience or global placeholders

Since:
1.0.0
See Also:
  • Method Details

    • platform

      public static Platform platform()
      Get the platform on which MiniPlaceholders is running.
      Returns:
      the platform
      Since:
      3.0.0
    • globalPlaceholders

      public static TagResolver globalPlaceholders()
      Get the global placeholders
      TagResolver resolver = MiniPlaceholders.globalPlaceholders();
       Component messageParsed = MiniMessage.miniMessage().deserialize(String, resolver);
      Returns:
      global placeholders independent of any audience
      Since:
      3.0.0
      See Also:
    • audiencePlaceholders

      public static TagResolver audiencePlaceholders()
      Gets the TagResolver that can get data from an Audience.
      The audience is provided at the time of parsing from the respective MiniMessage instance.
      TagResolver resolver = MiniPlaceholders.audiencePlaceholders();
       Component messageParsed = MiniMessage.miniMessage().deserialize(String, Audience, resolver);
       
      Returns:
      TagResolver with placeholders based on an audience
      Since:
      3.0.0
    • relationalPlaceholders

      public static TagResolver relationalPlaceholders()
      Get the relational placeholders based on two audiences
      The audiences are provided at the time of parsing from the respective MiniMessage instance through the use of a RelationalAudience.
      
            TagResolver resolver = MiniPlaceholders.relationalPlaceholders();
            Component parsed = MiniMessage.miniMessage().deserialize(@link String, {@link RelationalAudience}, resolver);
       
      Returns:
      placeholders based on two audiences
      Since:
      3.0.0
      See Also:
    • audienceGlobalPlaceholders

      public static TagResolver audienceGlobalPlaceholders()
      Get a TagResolver that can obtain data based on a relationship of 2 audiences and at the same time from the main audience and global placeholders.
      The audience is provided at the time of parsing from the respective MiniMessage instance.
       TagResolver resolver = MiniPlaceholders.audienceGlobalPlaceholders();
       TagResolver resolver2 = TagResolver.resolver(
        MiniPlaceholders.audienceGlobalPlaceholders(),
        MiniPlaceholders.globalPlaceholders()
       );
       // This two resolvers returns the same TagResolver
       assertEquals(resolver, resolver2);
       Component parsed = MiniMessage.miniMessage().deserialize(String, Audience, resolver);
       
      Returns:
      TagResolver with placeholders based on an audience and the global placeholders
      Since:
      1.1.0
    • relationalGlobalPlaceholders

      public static TagResolver relationalGlobalPlaceholders()
      Get the relational placeholders based on two audiences, based on the first audience, and the global placeholders
       TagResolver resolver = MiniPlaceholders.relationalGlobalPlaceholders();
       TagResolver resolver2 = TagResolver.resolver(
        MiniPlaceholders.relationalPlaceholders(),
        MiniPlaceholders.audiencePlaceholders(),
        MiniPlaceholders.globalPlaceholders()
       );
       // This methods should return the same TagResolver
       assertEquals(resolver, resolver2);
       Component messageParsed = MiniMessage.miniMessage().deserialize(String, RelationalAudience, resolver);
       
      Returns:
      the placeholders based on two audiences, placeholders based on the first audience and the global placeholders
      Since:
      3.0.0
      See Also:
      API Note:
      In the case of audience placeholders, the audience to be used will be the RelationalAudience.audience()
    • placeholdersByType

      public static TagResolver placeholdersByType(PlaceholderType type)
      Get a TagResolver based on the desired placeholder type.
      PlaceholderType.GLOBAL will return globalPlaceholders()
      PlaceholderType.AUDIENCE will return audiencePlaceholders()
      PlaceholderType.RELATIONAL will return relationalPlaceholders()
      Parameters:
      type - the desired type
      Returns:
      the TagResolvers from the respective type
      See Also:
    • expansionCount

      public static int expansionCount()
      Get the amount of expansion registered.
      Returns:
      the amount of expansions registered
      Since:
      3.0.0
    • expansionByName

      public static @Nullable Expansion expansionByName(String name)
      Get a specific expansion by name

      The name of each expansion is set when the expansion is created

           Expansion expansion = Expansion.builder("example").build();
           expansion.register();
      
           assertThat(MiniPlaceholders.expansionByName("example")).isNotNull();
       
      Parameters:
      name - the name of the required expansion
      Returns:
      the required expansion, if not present, will return null
      Since:
      3.0.0
      See Also:
    • expansionsAvailable

      public static @Unmodifiable Collection<Expansion> expansionsAvailable()
      Obtain all available registered expansions
      Returns:
      all available registered expansions
      Since:
      3.0.0