Class AudienceUtil

java.lang.Object
net.mathias2246.buildmc.util.AudienceUtil

public final class AudienceUtil extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static net.kyori.adventure.text.minimessage.tag.resolver.TagResolver.Single[]
    mapPlaceholders(Map<String,?> richPlaceholders)
     
    static @NotNull String
    renderPlainMessage(@NotNull org.bukkit.command.CommandSender sender, @NotNull String miniMessage, @NotNull Map<String,?> plainPlaceholders)
     
    static net.kyori.adventure.text.Component
    renderRichMessage(@NotNull org.bukkit.command.CommandSender sender, @NotNull String miniMessage, @NotNull Map<String,?> richPlaceholders)
    Resolves placeholders inside a MiniMessage string and renders translations using the GlobalTranslator.render(Component, Locale) method.
    static void
    sendActionBar(@NotNull net.kyori.adventure.audience.Audience audience, net.kyori.adventure.text.Component message)
     
    static void
    sendMessage(@NotNull net.kyori.adventure.audience.Audience audience, net.kyori.adventure.text.Component message)
     
    static void
    sendRichMessage(@NotNull org.bukkit.command.CommandSender sender, @NotNull String miniMessage, @NotNull Map<String,?> richPlaceholders)
    Resolves placeholders inside a MiniMessage string and displays it to a CommandSender.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AudienceUtil

      public AudienceUtil()
  • Method Details

    • sendMessage

      public static void sendMessage(@NotNull @NotNull net.kyori.adventure.audience.Audience audience, net.kyori.adventure.text.Component message)
    • sendActionBar

      public static void sendActionBar(@NotNull @NotNull net.kyori.adventure.audience.Audience audience, net.kyori.adventure.text.Component message)
    • sendRichMessage

      public static void sendRichMessage(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String miniMessage, @NotNull @NotNull Map<String,?> richPlaceholders)
      Resolves placeholders inside a MiniMessage string and displays it to a CommandSender.
      Parameters:
      sender - The CommandSender to send the rich message to.
      miniMessage - The MiniMessage string to parse.
      Resolves custom tags e.g. "Hello <player-name>!" using the entries inside the richPlaceholders map
      richPlaceholders - A Map of placeholders to resolve. The key is the name inside the custom mini message tag.
      The entry can be a Component or TagResolver.Single.
      Every other type will be converted using Object.toString() and is parsed as mini message text.
    • renderRichMessage

      public static net.kyori.adventure.text.Component renderRichMessage(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String miniMessage, @NotNull @NotNull Map<String,?> richPlaceholders)
      Resolves placeholders inside a MiniMessage string and renders translations using the GlobalTranslator.render(Component, Locale) method.

      This can be used for creating rendered component names for ItemStacks because TranslatableComponents cannot be translated on the server-side automatically.

      Parameters:
      sender - The CommandSender to send the rich message to.
      miniMessage - The MiniMessage string to parse.
      Resolves custom tags e.g. "Hello <player-name>!" using the entries inside the richPlaceholders map
      richPlaceholders - A Map of placeholders to resolve. The key is the name inside the custom mini message tag.
      The entry can be a Component or TagResolver.Single.
      Every other type will be converted using Object.toString() and is parsed as mini message text.
    • renderPlainMessage

      @NotNull public static @NotNull String renderPlainMessage(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String miniMessage, @NotNull @NotNull Map<String,?> plainPlaceholders)
    • mapPlaceholders

      public static net.kyori.adventure.text.minimessage.tag.resolver.TagResolver.Single[] mapPlaceholders(Map<String,?> richPlaceholders)