Interface NotificationService

All Superinterfaces:
BaseService
All Known Implementing Classes:
InMemoryNotificationService

public interface NotificationService extends BaseService
Sends short-lived notifications to one player: chat, title, action bar and a self-expiring boss bar. Text is rendered in the player's resolved locale. Methods may be called from any thread.

Required arguments reject null with a NullPointerException naming the parameter; an optional sound may be null.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Duration
    Default boss bar lifetime used by the short overloads.
    static final net.kyori.adventure.title.Title.Times
    Default title times, equivalent to the former 10/50/20 tick defaults.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    sendActionBarNotification(org.bukkit.entity.Player player, Text message)
    Shows text above the hotbar.
    default void
    sendBossBarNotification(org.bukkit.entity.Player player, Text message)
    Shows a green, continuous boss bar for the default lifetime without a sound.
    default void
    sendBossBarNotification(org.bukkit.entity.Player player, Text message, Duration duration)
    Shows a green, continuous boss bar for the given lifetime without a sound.
    void
    sendBossBarNotification(org.bukkit.entity.Player player, Text message, Duration duration, net.kyori.adventure.bossbar.BossBar.Color color, net.kyori.adventure.bossbar.BossBar.Overlay overlay, @Nullable net.kyori.adventure.sound.Sound sound)
    Shows a boss bar that empties over duration and then disappears.
    default void
    sendBossBarNotification(org.bukkit.entity.Player player, Text message, Duration duration, @Nullable net.kyori.adventure.sound.Sound sound)
    Shows a green, continuous boss bar with an optional sound.
    default void
    sendMessageNotification(org.bukkit.entity.Player player, Text message)
    Sends a chat message without a sound.
    void
    sendMessageNotification(org.bukkit.entity.Player player, Text message, @Nullable net.kyori.adventure.sound.Sound sound)
    Sends a chat message and optionally plays a sound to the player.
    default void
    sendSubTitleNotification(org.bukkit.entity.Player player, Text subtitle)
    Shows a subtitle and an empty title, without a sound.
    default void
    sendSubTitleNotification(org.bukkit.entity.Player player, Text subtitle, @Nullable net.kyori.adventure.sound.Sound sound)
    Shows a subtitle and an empty title with an optional sound.
    default void
    sendTitleNotification(org.bukkit.entity.Player player, Text title, Text subtitle)
    Shows a title and subtitle with the default times, without a sound.
    default void
    sendTitleNotification(org.bukkit.entity.Player player, Text title, Text subtitle, @Nullable net.kyori.adventure.sound.Sound sound)
    Shows a title and subtitle with the default times and an optional sound.
    void
    sendTitleNotification(org.bukkit.entity.Player player, Text title, Text subtitle, @Nullable net.kyori.adventure.sound.Sound sound, net.kyori.adventure.title.Title.Times times)
    Shows a title and subtitle with the given times and optionally plays a sound.

    Methods inherited from interface BaseService

    getAuthor, getName, getResourceFolderName, getVersion
  • Field Details

    • DEFAULT_BOSS_BAR_DURATION

      static final Duration DEFAULT_BOSS_BAR_DURATION
      Default boss bar lifetime used by the short overloads.
    • DEFAULT_TITLE_TIMES

      static final net.kyori.adventure.title.Title.Times DEFAULT_TITLE_TIMES
      Default title times, equivalent to the former 10/50/20 tick defaults.
  • Method Details

    • sendMessageNotification

      void sendMessageNotification(org.bukkit.entity.Player player, Text message, @Nullable @Nullable net.kyori.adventure.sound.Sound sound)
      Sends a chat message and optionally plays a sound to the player.
      Parameters:
      player - recipient
      message - deferred text
      sound - optional sound
    • sendMessageNotification

      default void sendMessageNotification(org.bukkit.entity.Player player, Text message)
      Sends a chat message without a sound.
      Parameters:
      player - recipient
      message - deferred text
    • sendTitleNotification

      void sendTitleNotification(org.bukkit.entity.Player player, Text title, Text subtitle, @Nullable @Nullable net.kyori.adventure.sound.Sound sound, net.kyori.adventure.title.Title.Times times)
      Shows a title and subtitle with the given times and optionally plays a sound.
      Parameters:
      player - recipient
      title - deferred title
      subtitle - deferred subtitle
      sound - optional sound
      times - fade-in, stay and fade-out durations
    • sendTitleNotification

      default void sendTitleNotification(org.bukkit.entity.Player player, Text title, Text subtitle)
      Shows a title and subtitle with the default times, without a sound.
      Parameters:
      player - recipient
      title - deferred title
      subtitle - deferred subtitle
    • sendTitleNotification

      default void sendTitleNotification(org.bukkit.entity.Player player, Text title, Text subtitle, @Nullable @Nullable net.kyori.adventure.sound.Sound sound)
      Shows a title and subtitle with the default times and an optional sound.
      Parameters:
      player - recipient
      title - deferred title
      subtitle - deferred subtitle
      sound - optional sound
    • sendSubTitleNotification

      default void sendSubTitleNotification(org.bukkit.entity.Player player, Text subtitle)
      Shows a subtitle and an empty title, without a sound.
      Parameters:
      player - recipient
      subtitle - deferred subtitle
    • sendSubTitleNotification

      default void sendSubTitleNotification(org.bukkit.entity.Player player, Text subtitle, @Nullable @Nullable net.kyori.adventure.sound.Sound sound)
      Shows a subtitle and an empty title with an optional sound.
      Parameters:
      player - recipient
      subtitle - deferred subtitle
      sound - optional sound
    • sendActionBarNotification

      void sendActionBarNotification(org.bukkit.entity.Player player, Text message)
      Shows text above the hotbar.
      Parameters:
      player - recipient
      message - deferred text
    • sendBossBarNotification

      void sendBossBarNotification(org.bukkit.entity.Player player, Text message, Duration duration, net.kyori.adventure.bossbar.BossBar.Color color, net.kyori.adventure.bossbar.BossBar.Overlay overlay, @Nullable @Nullable net.kyori.adventure.sound.Sound sound)
      Shows a boss bar that empties over duration and then disappears. A player has at most one such bar: a new call replaces its text, colour and overlay and restarts the countdown. The bar also disappears when the player leaves.
      Parameters:
      player - recipient
      message - deferred text
      duration - positive lifetime, rounded to the next 250 ms countdown step
      color - bar colour
      overlay - bar overlay
      sound - optional sound
      Throws:
      IllegalArgumentException - if duration is zero or negative
    • sendBossBarNotification

      default void sendBossBarNotification(org.bukkit.entity.Player player, Text message)
      Shows a green, continuous boss bar for the default lifetime without a sound.
      Parameters:
      player - recipient
      message - deferred text
    • sendBossBarNotification

      default void sendBossBarNotification(org.bukkit.entity.Player player, Text message, Duration duration)
      Shows a green, continuous boss bar for the given lifetime without a sound.
      Parameters:
      player - recipient
      message - deferred text
      duration - positive lifetime
    • sendBossBarNotification

      default void sendBossBarNotification(org.bukkit.entity.Player player, Text message, Duration duration, @Nullable @Nullable net.kyori.adventure.sound.Sound sound)
      Shows a green, continuous boss bar with an optional sound.
      Parameters:
      player - recipient
      message - deferred text
      duration - positive lifetime
      sound - optional sound