Class MessageSender

java.lang.Object
de.eldoria.eldoutilities.messages.MessageSender
Direct Known Subclasses:
PaperMessageSender, SpigotMessageSender

public abstract class MessageSender extends Object
A message sender to manage message sending.

Allows definition of a plugin prefix, Message color, Error color.

Allows sending of messages, error messages, titles.

Allows sending of automatically localized messages in combination with a created localizer.

Since:
1.0.0
  • Constructor Details

    • MessageSender

      public MessageSender(Plugin plugin, net.kyori.adventure.text.minimessage.MiniMessage miniMessage, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver messageTagResolver, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver errorTagResolver, net.kyori.adventure.text.Component prefix)
  • Method Details

    • register

      public static void register(MessageSender messageSender)
    • getPluginMessageSender

      public static MessageSender getPluginMessageSender(@NotNull @NotNull Plugin plugin)
      Get the message sender created for this plugin.
      Parameters:
      plugin - plugin
      Returns:
      message sender of plugin or default sender if plugin is null
    • builder

      public static MessageSenderBuilder builder(Plugin plugin)
    • getPluginMessageSender

      public static MessageSender getPluginMessageSender(@NotNull @NotNull Class<? extends Plugin> plugin)
      Get the message sender created for this plugin.
      Parameters:
      plugin - plugin
      Returns:
      message sender of plugin or default sender if plugin is null
    • sendMessage

      public void sendMessage(CommandSender sender, String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder)
      Send a message to a sender

      The message will be localized if a localizer is available and a locale code is detected.

      The message can be a simple locale code in the format "code.code....".

      Parameters:
      sender - receiver of the message
      message - message with optional color codes
    • sendMessage

      public void sendMessage(CommandSender sender, IMessageComposer composer)
      Send a message to a sender

      The message will be localized if a localizer is available and a locale code is detected.

      The message can be a simple locale code in the format "code.code....".

      Parameters:
      sender - receiver of the message
      composer - message composer
    • sendError

      public void sendError(CommandSender sender, String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder)
      Sends an error to a sender

      The message will be localized if a localizer is available and a locale code is detected.

      The message can be a simple locale code in the format "code.code....".

      Parameters:
      sender - receiver of the message
      message - message with optional color codes
    • sendError

      public void sendError(CommandSender sender, IMessageComposer composer)
      Sends an error to a sender

      The message will be localized if a localizer is available and a locale code is detected.

      The message can be a simple locale code in the format "code.code....".

      Parameters:
      sender - receiver of the message
      composer - message composer
    • sendMessage

      public abstract void sendMessage(CommandSender sender, net.kyori.adventure.text.Component component)
    • broadcast

      public abstract void broadcast(String message)
    • sendTitle

      public void sendTitle(Player player, String title, String subtitle, net.kyori.adventure.title.Title.Times times, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder)
      Send a localized title to a player
      Parameters:
      player - player to send
      title - title to send
    • sendTitle

      public abstract void sendTitle(Player player, net.kyori.adventure.title.Title title)
      Send a title to a player
      Parameters:
      player - player to send
      title - title to send
    • sendActionBar

      public abstract void sendActionBar(Player player, String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder)
      Send a localized action bar to a player
      Parameters:
      player - player to send
      message - message to send
    • sendErrorActionBar

      public abstract void sendErrorActionBar(Player player, String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder)
      Send a localized action bar to a player
      Parameters:
      player - player to send
      message - message to send
    • sendBossBar

      public abstract void sendBossBar(Player player, net.kyori.adventure.bossbar.BossBar bossBar)
    • sendBossBar

      public abstract net.kyori.adventure.bossbar.BossBar sendBossBar(Player player, String message, float progress, net.kyori.adventure.bossbar.BossBar.Color color, net.kyori.adventure.bossbar.BossBar.Overlay overlay, Set<net.kyori.adventure.bossbar.BossBar.Flag> flags)
    • hideBossBar

      public abstract void hideBossBar(Player player, net.kyori.adventure.bossbar.BossBar bossBar)
    • serialize

      protected net.kyori.adventure.text.Component serialize(CommandSender sender, String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver resolver, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder)
    • prefix

      public net.kyori.adventure.text.Component prefix()
    • applyPrefix

      protected net.kyori.adventure.text.Component applyPrefix(net.kyori.adventure.text.Component component)
    • translatePlain

      public String translatePlain(String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... replacements)
    • translatePlain

      public String translatePlain(@Nullable @Nullable CommandSender sender, String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... replacements)
    • serializeMessage

      public net.kyori.adventure.text.Component serializeMessage(String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder)
    • serializeMessage

      public net.kyori.adventure.text.Component serializeMessage(@Nullable @Nullable CommandSender sender, String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder)
    • serializeError

      public net.kyori.adventure.text.Component serializeError(String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder)
    • serializeError

      public net.kyori.adventure.text.Component serializeError(@Nullable @Nullable CommandSender sender, String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder)
    • miniMessage

      public net.kyori.adventure.text.minimessage.MiniMessage miniMessage()
    • isAnonymous

      public boolean isAnonymous()
    • messageTagResolver

      protected net.kyori.adventure.text.minimessage.tag.resolver.TagResolver messageTagResolver()
    • errorTagResolver

      protected net.kyori.adventure.text.minimessage.tag.resolver.TagResolver errorTagResolver()
    • plugin

      protected Plugin plugin()
    • asAudience

      public abstract net.kyori.adventure.audience.Audience asAudience(Player player)