Class InMemoryNotificationService

java.lang.Object
com.ultikits.ultitools.services.impl.InMemoryNotificationService
All Implemented Interfaces:
BaseService, NotificationService

public class InMemoryNotificationService extends Object implements NotificationService
Per-player notifications rendered by the text engine and owned by the framework scheduler.
  • Field Details

  • Constructor Details

    • InMemoryNotificationService

      public InMemoryNotificationService(Messages messages, Scheduler scheduler)
      Creates a notification service using the framework's root services.
      Parameters:
      messages - renderer capable of rendering every module namespace
      scheduler - framework-owned scheduler
  • Method Details

    • getName

      public String getName()
      Description copied from interface: BaseService
      Get service name, this name will appear in the console or in the game.
      Specified by:
      getName in interface BaseService
      Returns:
      Service name
    • getAuthor

      public String getAuthor()
      Specified by:
      getAuthor in interface BaseService
      Returns:
      Author name
    • getVersion

      public int getVersion()
      Description copied from interface: BaseService
      Version number, used to compare the version number of the registered service, currently not in use.
      Specified by:
      getVersion in interface BaseService
      Returns:
      service version
    • sendMessageNotification

      public void sendMessageNotification(org.bukkit.entity.Player player, Text message, @Nullable @Nullable net.kyori.adventure.sound.Sound sound)
      Description copied from interface: NotificationService
      Sends a chat message and optionally plays a sound to the player.
      Specified by:
      sendMessageNotification in interface NotificationService
      Parameters:
      player - recipient
      message - deferred text
      sound - optional sound
    • sendTitleNotification

      public 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)
      Description copied from interface: NotificationService
      Shows a title and subtitle with the given times and optionally plays a sound.
      Specified by:
      sendTitleNotification in interface NotificationService
      Parameters:
      player - recipient
      title - deferred title
      subtitle - deferred subtitle
      sound - optional sound
      times - fade-in, stay and fade-out durations
    • sendActionBarNotification

      public void sendActionBarNotification(org.bukkit.entity.Player player, Text message)
      Description copied from interface: NotificationService
      Shows text above the hotbar.
      Specified by:
      sendActionBarNotification in interface NotificationService
      Parameters:
      player - recipient
      message - deferred text
    • sendBossBarNotification

      public 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)
      Description copied from interface: NotificationService
      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.
      Specified by:
      sendBossBarNotification in interface NotificationService
      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
    • showBossBar

      private void showBossBar(org.bukkit.entity.Player player, net.kyori.adventure.text.Component name, net.kyori.adventure.bossbar.BossBar.Color color, net.kyori.adventure.bossbar.BossBar.Overlay overlay, @Nullable @Nullable net.kyori.adventure.sound.Sound sound, float decrement)
    • replaceBar

      private net.kyori.adventure.bossbar.BossBar replaceBar(org.bukkit.entity.Player player, @Nullable @Nullable InMemoryNotificationService.ActiveBar previous, net.kyori.adventure.text.Component name, net.kyori.adventure.bossbar.BossBar.Color color, net.kyori.adventure.bossbar.BossBar.Overlay overlay)
    • tick

      private void tick(org.bukkit.entity.Player player, net.kyori.adventure.bossbar.BossBar bar, TaskHandle handle, float decrement)
    • playSound

      private void playSound(org.bukkit.entity.Player player, @Nullable @Nullable net.kyori.adventure.sound.Sound sound)
    • activeBarCount

      int activeBarCount()